Esempio n. 1
0
 public IList <KeyValuePair <string, string> > GetValues()
 {
     return(new List <KeyValuePair <string, string> >()
     {
         new KeyValuePair <string, string>("Carton No", CartonNo.ToString()),
         new KeyValuePair <string, string>("Customer Code", CustomerCode),
         new KeyValuePair <string, string>("Name", Name),
         new KeyValuePair <string, string>("Status", Status),
         new KeyValuePair <string, string>("Status Confirmed", StatusConfirmed),
         new KeyValuePair <string, string>("Disposal Date", DisposalDate.HasValue ? DisposalDate.ToString() : string.Empty),
         new KeyValuePair <string, string>("Disposal Time",
                                           DisposalTimeFrame.HasValue ? DisposalTimeFrame.ToString() : string.Empty),
         new KeyValuePair <string, string>("First In Date", FirstInDate.ToString()),
         new KeyValuePair <string, string>("Last Transaction Date", LastTransactionDate.ToString())
     });
 }
Esempio n. 2
0
 public IList <KeyValuePair <string, string> > GetValues()
 {
     return(new List <KeyValuePair <string, string> >()
     {
         new KeyValuePair <string, string>("PickList No", PickListNo),
         new KeyValuePair <string, string>("Carton No", CartonNo.ToString()),
         new KeyValuePair <string, string>("Bar Code", Barcode),
         new KeyValuePair <string, string>("Location Code", LocationCode),
         new KeyValuePair <string, string>("WareHouse Code", WareHouseCode),
         new KeyValuePair <string, string>("Last SentDevice Id", LastSentDeviceId),
         new KeyValuePair <string, string>("Assigned User", AssignedUser),
         new KeyValuePair <string, string>("Request No", RequestNo),
         new KeyValuePair <string, string>("Picked User", PickedUser),
         new KeyValuePair <string, string>("IsPicked", IsPicked.ToString()),
         new KeyValuePair <string, string>("Pick Date", PickDate.ToString()),
         new KeyValuePair <string, string>("Deleted", Deleted.ToString()),
         new KeyValuePair <string, string>("Created User", CreatedUser),
         new KeyValuePair <string, string>("Created Date", CreatedDate),
         new KeyValuePair <string, string>("Lu User", LuUser.ToString()),
         new KeyValuePair <string, string>("Lu Date", LuDate)
     });
 }
Esempio n. 3
0
        protected bool ProcessSkid(GridViewRow gvr)
        {
            ImageButton    ib;
            string         s;
            int            SkidNo, BulkNo, CartonNo, Seq;
            int            CurrentSkid = 0, CurrentSkidSN = 0;
            int            CurrentBulk = 0, CurrentBulkSN = 0;
            decimal        CartonSN, SkidSN, BulkSN;
            TextBox        tb;
            HyperLink      hl;
            Label          lbl;
            string         sqlCmdDMSource;
            SqlConnection  scDMSource = new SqlConnection(ConfigurationManager.ConnectionStrings["DMSourceConnectionString"].ConnectionString);
            SqlCommand     scmdDMSource;
            SqlTransaction srcTransaction;
            SqlDataReader  sdrDMSource;
            bool           bSkidExists = false;
            bool           bBulkExists = false;


            tb  = (TextBox)gvr.FindControl("tbSkid");
            lbl = (Label)gvr.FindControl("lblStatus");

            // Get the current Skid for this row
            if (int.TryParse(tb.ToolTip, out CurrentSkid))
            {
            }
            else
            {
                CurrentSkid     = 0;
                lblMessage.Text = "Error Reading Skid #";
                return(true);
            }

            if (int.TryParse(tb.Text, out SkidNo))
            {
            }
            else
            {
                SkidNo = 0;
                // return false;
            }

            tb = (TextBox)gvr.FindControl("tbBulk");
            // Get the current Skid for this row
            if (int.TryParse(tb.ToolTip, out CurrentBulk))
            {
            }
            else
            {
                CurrentBulk = 0;
                lbl.Text    = "Error reading Bulk Carton #";
                return(true);
            }

            if (int.TryParse(tb.Text, out BulkNo))
            {
            }
            else
            {
                BulkNo = 0;
                // return false;
            }


            // Are we re-assigning the skid # / Bulk # here?
            if ((CurrentSkid != SkidNo) || (CurrentBulk != BulkNo))
            {
                if (SkidNo > 0)
                {
                    CurrentSkidSN = DataClass.CheckSkidLabel(lblPO.Text, SkidNo);
                    if (CurrentSkidSN > 0)
                    {
                        bSkidExists = true;
                    }
                }
                else
                {
                    // If Skid is 0, we aren't going to create it.
                    bSkidExists = true;
                }

                if (BulkNo > 0)
                {
                    CurrentBulkSN = DataClass.CheckBulkLabel(lblPO.Text, BulkNo);
                    if (CurrentBulkSN > 0)
                    {
                        bBulkExists = true;
                    }
                }
                else
                {
                    // If Bulk is 0, we aren't going to create it.
                    bBulkExists = true;
                }

                // Read out carton #
                if (int.TryParse(gvr.Cells[2].Text, out CartonNo))
                {
                }
                else
                {
                    lbl.Text = "Error reading Carton #";
                    return(true);
                }

                CartonSN = DataClass.GetCartonSN(lblPO.Text, CartonNo);
                scDMSource.Open();
                srcTransaction = scDMSource.BeginTransaction();
                try
                {
                    sqlCmdDMSource           = string.Concat("Update SL_Packing set Skid=", SkidNo.ToString(), ", BulkCarton=", BulkNo.ToString(), " Where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Carton=", CartonNo);
                    scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                    scmdDMSource.Transaction = srcTransaction;
                    if (scmdDMSource.ExecuteNonQuery() < 1)
                    {
                        tb.Text  = "";
                        lbl.Text = "Critical Error Updating Packing Records.";
                        srcTransaction.Rollback();
                        scDMSource.Close();
                        return(true);
                    }
                    else
                    {
                        // Then update skid # on this CartonNo
                        sqlCmdDMSource           = string.Concat("Update SL_Labels set Skid=", SkidNo.ToString(), ", BulkCarton=", BulkNo.ToString(), " where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Carton=", CartonNo.ToString());
                        scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                        scmdDMSource.Transaction = srcTransaction;
                        if (scmdDMSource.ExecuteNonQuery() < 1)
                        {
                            tb.Text  = "";
                            lbl.Text = string.Concat("Critical Error : Skid/Bulk on Carton # ", CartonNo.ToString());
                            srcTransaction.Rollback();
                            scDMSource.Close();
                            return(true);
                        }

                        if (!bBulkExists)
                        {
                            BulkSN = DataClass.GetNextBulk(lblPO.Text, BulkNo);
                            // Now insert Label record into SL_Labels table
                            sqlCmdDMSource           = string.Concat("Insert Into SL_Labels (SkidSN, BulkSN, PackingSeq, Vendor, PO, Description, Seq, Skid, BulkCarton, Carton, Status, PrintStatus) values (0, ", BulkSN.ToString(), ", 0, ", VendorList, ", '", lblPO.Text, "', 'Bulk Label ", BulkNo.ToString(), "', 0, ", SkidNo.ToString(), ", ", BulkNo.ToString(), ",0,'A','')");
                            scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                            scmdDMSource.Transaction = srcTransaction;
                            if (scmdDMSource.ExecuteNonQuery() < 1)
                            {
                                tb.Text  = "";
                                lbl.Text = "Critical Error Creating Bulk Label Record.";
                                srcTransaction.Rollback();
                                scDMSource.Close();
                                return(true);
                            }
                        }
                        else
                        {
                            // We are removing from a skid, check if anything is left on the skid and remove the label if necessary.
                            sqlCmdDMSource           = string.Concat("Select * from SL_Labels where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and BulkCarton=", CurrentBulk.ToString(), " and Carton<>0");
                            scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                            scmdDMSource.Transaction = srcTransaction;
                            sdrDMSource = scmdDMSource.ExecuteReader();
                            if (!sdrDMSource.HasRows)
                            {
                                sdrDMSource.Close();
                                // There is nothing else on this BulkCarton, time to remove it's label
                                sqlCmdDMSource           = string.Concat("Delete from SL_Labels where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and BulkCarton=", CurrentBulk.ToString(), " and Carton=0");
                                scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                                scmdDMSource.Transaction = srcTransaction;
                                scmdDMSource.ExecuteNonQuery();

                                // Now delete the skid
                                sqlCmdDMSource           = string.Concat("Delete from SL_Bulk where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and BulkCarton=", CurrentBulk.ToString());
                                scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                                scmdDMSource.Transaction = srcTransaction;
                                scmdDMSource.ExecuteNonQuery();
                            }
                            else
                            {
                                sdrDMSource.Close();
                            }
                        }

                        // Updated Packing information with the Skid, create the label record
                        if (!bSkidExists)
                        {
                            //// OK, Skid doesn't exist, get Seq from the Carton we are updating
                            //sqlCmdDMSource = string.Concat("Select Seq from SL_Labels where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Carton=", CartonNo.ToString());
                            //scmdDMSource = new SqlCommand(sqlCmdDMSource, scDMSource);
                            //scmdDMSource.Transaction = srcTransaction;
                            //sdrDMSource = scmdDMSource.ExecuteReader();
                            //if (sdrDMSource.HasRows)
                            //{
                            //    sdrDMSource.Read();
                            //    Seq = (int)sdrDMSource["Seq"];
                            //    sdrDMSource.Close();
                            //}
                            //else
                            //{
                            //    Seq = 1;
                            //}
                            //// Then update sequence of all cartons >= selected CartonNo
                            //sqlCmdDMSource = string.Concat("Update SL_Labels set Seq=Seq+1 where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Seq>=", Seq.ToString());
                            //scmdDMSource = new SqlCommand(sqlCmdDMSource, scDMSource);
                            //scmdDMSource.Transaction = srcTransaction;
                            //if (scmdDMSource.ExecuteNonQuery() < 1)
                            //{
                            //    tb.Text = "";
                            //    lbl.Text = "Critical Error Updating Carton Label Records: Sequence Insert.";
                            //    srcTransaction.Rollback();
                            //    scDMSource.Close();
                            //    return true;
                            //}
                            //else
                            //{
                            SkidSN = DataClass.GetNextSkid(lblPO.Text, SkidNo);
                            // Now insert Label record into SL_Labels table
                            sqlCmdDMSource           = string.Concat("Insert Into SL_Labels (SkidSN, BulkSN, PackingSeq, Vendor, PO, Description, Seq, Skid, BulkCarton, Carton, Status, PrintStatus) values (", SkidSN.ToString(), ", 0, 0, ", VendorList, ", '", lblPO.Text, "', 'Skid Label ", SkidNo.ToString(), "', 0, ", SkidNo.ToString(), ", ", BulkNo.ToString(), ",0,'A','')");
                            scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                            scmdDMSource.Transaction = srcTransaction;
                            if (scmdDMSource.ExecuteNonQuery() < 1)
                            {
                                tb.Text  = "";
                                lbl.Text = "Critical Error Creating Skid Label Record.";
                                srcTransaction.Rollback();
                                scDMSource.Close();
                                return(true);
                            }

                            // Update Skid # on Label
                            // Commented 6/18/2020, will insert upon printing
                            //sqlCmdDMSource = string.Concat("Insert into SL_Operations (SerialNo, Vendor, PO, Line, Item, Component, Description, ShipQty, Operation, CartonNo, OfCartons, SkidSerialNo, Status) Values (", CartonSN.ToString(), ", ", VendorList, ", '", lblPO.Text, "', '', '', '', '', 0, 'U', 0, 0, ", SkidSN.ToString(), ", 'N') ");
                            //scmdDMSource = new SqlCommand(sqlCmdDMSource, scDMSource);
                            //scmdDMSource.Transaction = srcTransaction;
                            //scmdDMSource.ExecuteNonQuery();
                            // }
                        }
                        else
                        {
                            // We aren't creating a skid, assign the existing found Skid #
                            int UpdateSkidSN = 0;
                            if (SkidNo != 0)
                            {
                                UpdateSkidSN = CurrentSkidSN;
                                // If we aren't creating the Skid, find it's serial # and then update the label
                                // Now insert Label record into SL_Labels table
                                // Update Skid # on Label
                            }
                            else
                            {
                                // We are removing from a skid, check if anything is left on the skid and remove the label if necessary.
                                sqlCmdDMSource           = string.Concat("Select * from SL_Labels where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Skid=", CurrentSkid.ToString(), " and Carton<>0");
                                scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                                scmdDMSource.Transaction = srcTransaction;
                                sdrDMSource = scmdDMSource.ExecuteReader();
                                if (!sdrDMSource.HasRows)
                                {
                                    sdrDMSource.Close();

                                    // Nothing left on the skid, lets remove and resequence
                                    // First get the sequence of this skid #
                                    //sqlCmdDMSource = string.Concat("Select * from SL_Labels where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Skid=", CurrentSkid.ToString(), " and Carton=0");
                                    //scmdDMSource = new SqlCommand(sqlCmdDMSource, scDMSource);
                                    //scmdDMSource.Transaction = srcTransaction;
                                    //sdrDMSource = scmdDMSource.ExecuteReader();
                                    //if (sdrDMSource.HasRows)
                                    //{
                                    //    sdrDMSource.Read();
                                    //    Seq = (int)sdrDMSource["Seq"];

                                    //    // Then update sequence of all cartons >= selected CartonNo
                                    //    sqlCmdDMSource = string.Concat("Update SL_Labels set Seq=Seq-1 where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Seq>", Seq.ToString());
                                    //    scmdDMSource = new SqlCommand(sqlCmdDMSource, scDMSource);
                                    //    scmdDMSource.Transaction = srcTransaction;
                                    //    if (scmdDMSource.ExecuteNonQuery() < 1)
                                    //    {
                                    //        tb.Text = "";
                                    //        lbl.Text = "Critical Error Updating Carton Label Records: Sequence Removal.";
                                    //        srcTransaction.Rollback();
                                    //        scDMSource.Close();
                                    //        return true;
                                    //    }
                                    //}
                                    //sdrDMSource.Close();


                                    // There is nothing else on this skid, time to remove it's label
                                    sqlCmdDMSource           = string.Concat("Delete from SL_Labels where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Skid=", CurrentSkid.ToString(), " and Carton=0");
                                    scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                                    scmdDMSource.Transaction = srcTransaction;
                                    scmdDMSource.ExecuteNonQuery();

                                    // Now delete the skid
                                    sqlCmdDMSource           = string.Concat("Delete from SL_Skids where (Vendor=", VendorList, ") and PO='", lblPO.Text, "' and Skid=", CurrentSkid.ToString());
                                    scmdDMSource             = new SqlCommand(sqlCmdDMSource, scDMSource);
                                    scmdDMSource.Transaction = srcTransaction;
                                    scmdDMSource.ExecuteNonQuery();
                                }
                                else
                                {
                                    sdrDMSource.Close();
                                }
                            }
                            // Commented 6/18/2020, SL_Operations will be updated upon printing
                            //sqlCmdDMSource = string.Concat("Insert into SL_Operations (SerialNo, Vendor, PO, Line, Item, Component, Description, ShipQty, Operation, CartonNo, OfCartons, SkidSerialNo, Status) Values (", CartonSN.ToString(), ", ", VendorList, ", '", lblPO.Text, "', '', '', '', '', 0, 'U', 0, 0, ", UpdateSkidSN.ToString(), ", 'N') ");
                            //scmdDMSource = new SqlCommand(sqlCmdDMSource, scDMSource);
                            //scmdDMSource.Transaction = srcTransaction;
                            //scmdDMSource.ExecuteNonQuery();
                        }
                    }
                    // Close SQL Connection
                    srcTransaction.Commit();
                    scDMSource.Close();
                    if ((SkidNo == 0) && (BulkNo == 0))
                    {
                        lbl.Text = string.Concat("Carton ", CartonNo.ToString(), " removed from Bulk/Skid.");
                    }
                    else
                    {
                        lbl.Text = string.Concat("Carton ", CartonNo.ToString(), " added to Bulk # ", BulkNo.ToString(), " Skid # ", SkidNo.ToString());
                    }
                }
                catch (Exception ex)
                {
                    lbl.Text = "Critical Unhandled Exception.";
                    srcTransaction.Rollback();
                    scDMSource.Close();
                }
                tb.ToolTip = SkidNo.ToString();
            }
            else
            {
                lbl.Text = "";
            }
            return(false);
        }