Click here to Skip to main content
15,900,973 members
Home / Discussions / C#
   

C#

 
GeneralRe: Coding error missing reference Pin
Pete O'Hanlon31-Mar-18 10:12
mvePete O'Hanlon31-Mar-18 10:12 
QuestionProblem with Rotating Platforms in Unity 3D Pin
O.G.I.30-Mar-18 8:06
O.G.I.30-Mar-18 8:06 
AnswerRe: Problem with Rotating Platforms in Unity 3D Pin
Eddy Vluggen30-Mar-18 22:48
professionalEddy Vluggen30-Mar-18 22:48 
GeneralRe: Problem with Rotating Platforms in Unity 3D Pin
O.G.I.30-Mar-18 23:51
O.G.I.30-Mar-18 23:51 
GeneralRe: Problem with Rotating Platforms in Unity 3D Pin
Eddy Vluggen31-Mar-18 3:10
professionalEddy Vluggen31-Mar-18 3:10 
QuestionIPv6 based UDP client which can communicate with 3rd Part IPv6 based UDP Server Pin
SKant0330-Mar-18 0:15
SKant0330-Mar-18 0:15 
AnswerRe: IPv6 based UDP client which can communicate with 3rd Part IPv6 based UDP Server Pin
Gerry Schmitz31-Mar-18 6:50
mveGerry Schmitz31-Mar-18 6:50 
QuestionHow to fix this? Please see my code if what is the solution for 'AssetService.InsertPulloutReturnItems(string, string, string, string)': not all code paths return value.. Thanks Pin
arthur tarrayo29-Mar-18 21:05
arthur tarrayo29-Mar-18 21:05 
C#
public PulloutReturnResponse InsertPulloutReturnItems(String Barcode, String Details, String Status, String Actor, String Attachment, String CheckedBy)
    {
        //int isPulledout = 0;
        try 
        {
                using (MySqlConnection mycon = dbcon.getConnection())
                {
                    using (MySqlCommand mycmd = mycon.CreateCommand())
                    {
                        if (Status == "2")
                        {
                            mycmd.CommandText = "SELECT barcode FROM AssetManagementDB.PulloutReturn WHERE barcode = <a href="https://www.codeproject.com/Members/BarCode">@barcode</a> AND status = <a href="https://www.codeproject.com/Members/status">@status</a> ";
                            mycmd.Parameters.Clear();
                            mycmd.Parameters.AddWithValue("@barcode", Barcode);
                            mycmd.Parameters.AddWithValue("@status", Status);
                            mycon.Open();
                            MySqlDataReader rdr = mycmd.ExecuteReader();
                            if (rdr.HasRows)
                            {
                                rdr.Dispose();
                                rdr.Close();
                                mycon.Close();
                                _assetlog.Info("Barcode: " + Barcode + "Details: " + Details + "Status: " + Status +
                                                 "Actor: " + Actor + "Attachment: " + Attachment + "CheckedBy: " + CheckedBy);
                                return new PulloutReturnResponse { RespCode = -1, RespMsg = "Asset already Pulled-out!" };
                            }
                            rdr.Dispose();
                            rdr.Close();
                            mycon.Close();

                            mycmd.CommandText = " UPDATE AssetManagementDB.PulloutReturn " +
                                                " SET PulloutReturn.status = <a href="https://www.codeproject.com/Members/status">@status</a> AND isPulledout = 1 AND sysmodified = NOW() " +
                                                " WHERE barcode = <a href="https://www.codeproject.com/Members/BarCode">@barcode</a> ";
                            mycmd.Parameters.Clear();
                            mycmd.Parameters.AddWithValue("@barcode", Barcode);
                            mycmd.Parameters.AddWithValue("@status", Status);
                            mycon.Open();
                            mycmd.Transaction = mycon.BeginTransaction();
                            int i = mycmd.ExecuteNonQuery();

                            if (i >= 1)
                            {
                                _assetlog.Info("Barcode: " + Barcode + "Details: " + Details + "Status: " + Status +
                                                "Actor: " + Actor + "Attachment: " + Attachment + "CheckedBy: " + CheckedBy);

                                mycmd.CommandText = "UPDATE AssetManagementDB.ItemEntry SET status = <a href="https://www.codeproject.com/Members/status">@status</a> AND sysmodified = Now() WHERE barcode = <a href="https://www.codeproject.com/Members/BarCode">@barcode</a> ";
                                mycmd.Parameters.Clear();
                                mycmd.Parameters.AddWithValue("@status", Status);
                                mycmd.Parameters.AddWithValue("@barcode", Barcode);
                                i = mycmd.ExecuteNonQuery();
                                if (i >= 1)
                                {
                                    mycmd.Transaction.Commit();
                                    mycon.Close();
                                    return new PulloutReturnResponse { RespCode = 1, RespMsg = "Succesfully Pulled-out Item!" };
                                }
                                mycmd.Transaction.Rollback();
                                mycon.Close();
                                return new PulloutReturnResponse { RespCode = -1, RespMsg = "Saving Failed!" };
                            }                           
                        }
                        if (Status == "3")
                        {
                            mycmd.CommandText = "SELECT barcode FROM AssetManagementDB.PulloutReturn WHERE barcode = <a href="https://www.codeproject.com/Members/BarCode">@barcode</a> AND status = <a href="https://www.codeproject.com/Members/status">@status</a> ";
                            mycmd.Parameters.Clear();
                            mycmd.Parameters.AddWithValue("@barcode", Barcode);
                            mycmd.Parameters.AddWithValue("@status", Status);
                            mycon.Open();
                            MySqlDataReader rdr = mycmd.ExecuteReader();
                            if (rdr.HasRows)
                            {
                                rdr.Dispose();
                                rdr.Close();
                                mycon.Close();
                                _assetlog.Info("Barcode: " + Barcode + "Details: " + Details + "Status: " + Status +
                                                 "Actor: " + Actor + "Attachment: " + Attachment + "CheckedBy: " + CheckedBy);
                                return new PulloutReturnResponse { RespCode = -1, RespMsg = "Asset already Pulled-out!" };
                            }
                            rdr.Dispose();
                            rdr.Close();
                            mycon.Close();

                            mycmd.CommandText = " UPDATE AssetManagementDB.PulloutReturn " +
                                                " SET PulloutReturn.status = <a href="https://www.codeproject.com/Members/status">@status</a> AND isPulledout = 0 AND sysmodified = NOW() " +
                                                " WHERE barcode = <a href="https://www.codeproject.com/Members/BarCode">@barcode</a> ";
                            mycmd.Parameters.Clear();
                            mycmd.Parameters.AddWithValue("@barcode", Barcode);
                            mycmd.Parameters.AddWithValue("@status", Status);
                            mycon.Open();
                            mycmd.Transaction = mycon.BeginTransaction();
                            int i = mycmd.ExecuteNonQuery();

                            if (i >= 1)
                            {
                                _assetlog.Info("Barcode: " + Barcode + "Details: " + Details + "Status: " + Status +
                                                "Actor: " + Actor + "Attachment: " + Attachment + "CheckedBy: " + CheckedBy);

                                mycmd.CommandText = "UPDATE AssetManagementDB.ItemEntry SET status = <a href="https://www.codeproject.com/Members/status">@status</a> AND sysmodified = Now() WHERE barcode = <a href="https://www.codeproject.com/Members/BarCode">@barcode</a> ";
                                mycmd.Parameters.Clear();
                                mycmd.Parameters.AddWithValue("@status", Status);
                                mycmd.Parameters.AddWithValue("@barcode", Barcode);
                                i = mycmd.ExecuteNonQuery();
                                if (i >= 1)
                                {
                                    mycmd.Transaction.Commit();
                                    mycon.Close();
                                    return new PulloutReturnResponse { RespCode = 1, RespMsg = "Succesfully Returned Item!" };
                                }
                                mycmd.Transaction.Rollback();
                                mycon.Close();
                                return new PulloutReturnResponse { RespCode = -1, RespMsg = "Saving Failed!" };
                            }                           
                        }
                        else
                        {
                            mycmd.Transaction.Rollback();
                            _assetlog.Info("Barcode: " + Barcode + "Details: " + Details + "Status: " + Status +
                                            "Actor: " + Actor + "Attachment: " + Attachment + "Checked By: " + CheckedBy);
                            return new PulloutReturnResponse { RespCode = -1, RespMsg = "Saving Failed!" };
                        }
                    }
                }
        }
        catch (Exception ex)
        {
            _assetlog.Fatal("Error: " + ex.Message.ToString());
            return new PulloutReturnResponse { RespCode = -1, RespMsg = ex.Message };
        }
    }

arthur


modified 30-Mar-18 3:17am.

AnswerRe: How to fix this? Please see my code if what is the solution for 'AssetService.InsertPulloutReturnItems(string, string, string, string)': not all code paths return value.. Thanks Pin
OriginalGriff29-Mar-18 21:23
mveOriginalGriff29-Mar-18 21:23 
QuestionBuilding custom controls from common wpf controls Pin
Dwayne Barsotta29-Mar-18 2:37
Dwayne Barsotta29-Mar-18 2:37 
AnswerRe: Building custom controls from common wpf controls Pin
Gerry Schmitz29-Mar-18 6:43
mveGerry Schmitz29-Mar-18 6:43 
GeneralRe: Building custom controls from common wpf controls Pin
BillWoodruff30-Mar-18 4:14
professionalBillWoodruff30-Mar-18 4:14 
GeneralRe: Building custom controls from common wpf controls Pin
Gerry Schmitz30-Mar-18 4:45
mveGerry Schmitz30-Mar-18 4:45 
GeneralRe: Building custom controls from common wpf controls Pin
BillWoodruff30-Mar-18 19:55
professionalBillWoodruff30-Mar-18 19:55 
AnswerRe: Building custom controls from common wpf controls Pin
Mycroft Holmes29-Mar-18 15:19
professionalMycroft Holmes29-Mar-18 15:19 
AnswerRe: Building custom controls from common wpf controls Pin
BillWoodruff30-Mar-18 4:05
professionalBillWoodruff30-Mar-18 4:05 
QuestionWpf frameworks or styles Pin
Dwayne Barsotta29-Mar-18 2:24
Dwayne Barsotta29-Mar-18 2:24 
AnswerRe: Wpf frameworks or styles Pin
Pete O'Hanlon29-Mar-18 2:52
mvePete O'Hanlon29-Mar-18 2:52 
AnswerRe: Wpf frameworks or styles Pin
Gerry Schmitz29-Mar-18 6:55
mveGerry Schmitz29-Mar-18 6:55 
QuestionHow to print a recording Pin
ago248628-Mar-18 23:31
ago248628-Mar-18 23:31 
AnswerRe: How to print a recording Pin
OriginalGriff28-Mar-18 23:36
mveOriginalGriff28-Mar-18 23:36 
GeneralRe: How to print a recording Pin
ago248628-Mar-18 23:41
ago248628-Mar-18 23:41 
GeneralRe: How to print a recording Pin
OriginalGriff28-Mar-18 23:49
mveOriginalGriff28-Mar-18 23:49 
GeneralRe: How to print a recording Pin
ago248629-Mar-18 0:04
ago248629-Mar-18 0:04 
GeneralRe: How to print a recording Pin
OriginalGriff29-Mar-18 0:11
mveOriginalGriff29-Mar-18 0:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.