예제 #1
0
        public RPDBatchProduction Get(String RPDBatchID, String MaterialCode)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@RPDBatchID", RPDBatchID),
                    new SqlParameter("@MaterialCode", MaterialCode)
                };


                DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_RPDBatchProduction_By_ID", paramList);

                RPDBatchProduction obj = new RPDBatchProduction();

                if (dt.Rows.Count > 0)
                {
                    obj.RPDBatch         = objRPDBatch_DL.Get(Convert.ToString(dt.Rows[0]["RPDBatchID"]));
                    obj.MaterialQuantity = Convert.ToDecimal(dt.Rows[0]["Qty"]);
                    obj.Material         = objMaterial_DL.Get(Convert.ToString(dt.Rows[0]["MaterialCode"]));
                }

                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
예제 #2
0
 private void ClearProduction()
 {
     if (cmbMaterialInter.Items.Count > 0)
     {
         cmbMaterialInter.SelectedIndex = 0;
     }
     txtMaterialQty.Text       = "0.00";
     objRPDBatchProduction     = null;
     btnMaterialDelete.Enabled = false;
 }
예제 #3
0
        private void btnAddMaterial_Click(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToDecimal(txtMaterialQty.Text) <= 0)
                {
                    MessageBox.Show(this, "Invalid Quantity", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    String OriginalMaterilCode = "";
                    if (objRPDBatchProduction != null)
                    {
                        OriginalMaterilCode = objRPDBatchProduction.Material.MaterialCode;
                    }
                    else
                    {
                        objRPDBatchProduction = new RPDBatchProduction();
                    }
                    objRPDBatchProduction.Material         = objMaterialDL.Get(cmbMaterialInter.SelectedValue.ToString());
                    objRPDBatchProduction.MaterialQuantity = Convert.ToDecimal(txtMaterialQty.Text);
                    objRPDBatchProduction.RPDBatch         = objRPDBatch;
                    int res = objRPDBatchProductionDL.Add(objRPDBatchProduction, OriginalMaterilCode);
                    if (res > 0)
                    {
                        ClearProduction();

                        gvProduction.AutoGenerateColumns = false;
                        bindProduction.DataSource        = objRPDBatchProductionDL.GetDataByBatchID(objRPDBatch.RPDBatchID);
                        gvProduction.DataSource          = bindProduction;
                        bindProduction.ResetBindings(true);
                    }
                }
            }
            catch (SqlException sqlex)
            {
                if (sqlex.Number == 2627)
                {
                    MessageBox.Show(this, "Selected material already added", "Duplicate Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(this, "SQL error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while saving production details", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #4
0
        private void gvProduction_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                String Material = (gvProduction.Rows[e.RowIndex].Cells["MaterialCode"].Value.ToString());

                objRPDBatchProduction          = objRPDBatchProductionDL.Get(objRPDBatch.RPDBatchID, Material);
                txtMaterialQty.Text            = objRPDBatchProduction.MaterialQuantity.ToString();
                cmbMaterialInter.SelectedValue = objRPDBatchProduction.Material.MaterialCode;
                btnMaterialDelete.Enabled      = true;
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while selecting record", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #5
0
        public int Update(RPDBatchProduction obj)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@RPDBatchID", obj.RPDBatch),
                    new SqlParameter("@MaterialCode", obj.Material),
                    new SqlParameter("@Qty", obj.MaterialQuantity)
                };

                return(Execute.RunSP_RowsEffected(Connection, "SPUPDATE_RPDBatchProduction", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
예제 #6
0
        public int Add(RPDBatchProduction obj, String OriginalMaterialCode)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@RPDBatchID", obj.RPDBatch.RPDBatchID),
                    new SqlParameter("@MaterialCode", obj.Material.MaterialCode),
                    new SqlParameter("@OriginalMaterialCode", obj.Material.MaterialCode),
                    new SqlParameter("@Qty", obj.MaterialQuantity)
                };

                return(Execute.RunSP_RowsEffected(Connection, "SPADD_RPDBatchProduction_Update", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }