Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dtBatches = objBatch_DL.Get_DataView_Packing_All(Batch.Status.In_Progress, Batch.Status.QC, Batch.Status.QCPass, Batch.Status.Packing, Batch.Status.Finished, CurrentUser.UserID, "Product");

                DataTable dtBatches_Rework = objBatch_DL.Get_DataView_Rework(Batch.Status.In_Progress, "Rework", "Repack");

                bool isaValidBatch = false;

                for (int i = 0; i < dtBatches.Rows.Count; i++)
                {
                    if (dtBatches.Rows[i]["BatchID"].ToString() == txtBatchNo.Text)
                    {
                        isaValidBatch = true;
                        break;
                    }
                }

                for (int i = 0; i < dtBatches_Rework.Rows.Count; i++)
                {
                    if (dtBatches_Rework.Rows[i]["BatchID"].ToString() == txtBatchNo.Text)
                    {
                        isaValidBatch = true;
                        break;
                    }
                }

                if (isaValidBatch == true)
                {
                    objBatch = objBatch_DL.Get(txtBatchNo.Text);

                    if (objMRMaterialCollec.Count > 0)
                    {
                        long MRNO = objMRDL.Add_BatchMR_Packing("A", objBatch.BatchID, objStore.StoreID, CurrentUser.UserEmp.EmployeeID, "Batch MR to" + objBatch.BatchID, MR.Status.Initial, MR.Type.Material, (int)MR.Origin.ToBatch);
                        if (MRNO > 0)
                        {
                            objMR.MRNO = MRNO;
                            foreach (MRMaterial obj in objMRMaterialCollec)
                            {
                                obj.MR = objMR;
                                objMRMaterialDL.Add(obj);
                            }
                            MessageBox.Show(this, "Successfully Added to Database", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearItem();
                            ClearMR();
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "Item List is Empty,Please add Items before continue", "Item List is Empty", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(this, "Not a Valid Batch To Send MR", "UnSuccessfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                txtBatchNo.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }