Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MTNMaterial      objMTNMat    = new MTNMaterial();
            MTNBasicProduct  objMTNBasic  = new MTNBasicProduct();
            MTNFinishProduct objMTNFinish = new MTNFinishProduct();

            Department objDepFrom = new Department();
            Department objDepTo   = new Department();

            Store         objStore         = new Store();
            Material      objMaterial      = new Material();
            FinishProduct objFinishProduct = new FinishProduct();
            BasicProduct  objBasicProduct  = new BasicProduct();
            GRN           objGRN           = new GRN();

            try
            {
                String ItemCode = "";
                if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null)
                {
                    ItemCode = cmbItem.SelectedValue.ToString();
                }


                if (cmbDepartmentFrom.Items.Count > 0)
                {
                    objDepFrom = (Department)cmbDepartmentFrom.SelectedItem;
                    objDepTo   = (Department)cmbDepartmentFrom.SelectedItem;
                }

                if (cmbStoreFrom.Items.Count > 0)
                {
                    objStore = (Store)cmbStoreFrom.SelectedItem;
                }

                objMTN.MTNDepartmentFrom = objDepFrom;
                objMTN.MTNDepartmentTo   = objDepTo;
                objMTN.MTNEnterdBy       = CurrentUser.UserEmp;
                objMTN.MTNStatus         = MTN.Status.Initial;
                objMTN.MTNType           = MTN.Type.Dispose;
                objMTN.MTNStore          = objStore;
                if (cmbMTNType.SelectedItem.Equals("Basic Product"))
                {
                    objMTN.MTNItemType = MTN.ItemType.Basic_Product;


                    objMTN.MTNNo = objMTNDL.Add_Other(objMTN);

                    if (objMTN.MTNNo > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            objBasicProduct          = objBasicProductDL.Get(dr["ItemCode"].ToString());
                            objMTNBasic.Batch        = "";
                            objMTNBasic.Description  = dr["Remarks"].ToString();
                            objMTNBasic.BasicProduct = objBasicProduct;
                            objMTNBasic.MTN          = objMTN;
                            objMTNBasic.TransferQty  = Convert.ToDecimal(dr["Qty"].ToString());
                            objMTNBasicProductDL.Add(objMTNBasic);
                        }
                    }
                }
                else if (cmbMTNType.SelectedItem.Equals("Material"))
                {
                    objMTN.MTNItemType = MTN.ItemType.Material;


                    objMTN.MTNNo = objMTNDL.Add_Other(objMTN);

                    if (objMTN.MTNNo > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            objMaterial = objMaterialDL.Get(dr["ItemCode"].ToString());


                            objMTNMat.Batch       = "";
                            objMTNMat.Description = dr["Remarks"].ToString();
                            objMTNMat.Material    = objMaterial;
                            objMTNMat.MTN         = objMTN;
                            objMTNMat.TransferQty = Convert.ToDecimal(dr["Qty"]);
                            objMTNMaterialDL.Add(objMTNMat);
                        }
                    }
                }
                else if (cmbMTNType.SelectedItem.Equals("Finish Product"))
                {
                    objMTN.MTNItemType = MTN.ItemType.Finish_Product;


                    objMTN.MTNNo = objMTNDL.Add_Other(objMTN);

                    if (objMTN.MTNNo > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            objFinishProduct           = objFinishProductDL.Get((cmbItem.SelectedValue.ToString()));
                            objMTNFinish.Batch         = "";
                            objMTNFinish.Description   = dr["Remarks"].ToString();
                            objMTNFinish.FinishProduct = objFinishProduct;
                            objMTNFinish.MTN           = objMTN;
                            objMTNFinish.TransferQty   = Convert.ToDecimal(dr["Qty"]);
                            objMTNFinisProductDL.Add(objMTNFinish);
                        }
                    }
                }
                int x = Approve();
                if (x > 0)
                {
                    MessageBox.Show(this, "Stock Reduced", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MTNMaterial      objMTNMat    = new MTNMaterial();
            MTNBasicProduct  objMTNBasic  = new MTNBasicProduct();
            MTNFinishProduct objMTNFinish = new MTNFinishProduct();

            Department objDepFrom = new Department();
            Department objDepTo   = new Department();

            Store         objStore         = new Store();
            Material      objMaterial      = new Material();
            FinishProduct objFinishProduct = new FinishProduct();
            BasicProduct  objBasicProduct  = new BasicProduct();
            GRN           objGRN           = new GRN();

            try
            {
                if (cmbGRNNO.Items.Count > 0 && cmbGRNNO.SelectedValue != null)
                {
                    objGRN.GRNNo = Convert.ToInt64(cmbGRNNO.SelectedValue);
                }

                String ItemCode = "";
                if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null)
                {
                    ItemCode = cmbItem.SelectedValue.ToString();
                }


                if (cmbDepartmentFrom.Items.Count > 0)
                {
                    objDepFrom = objDepartmentDL.Get(Convert.ToInt64(cmbDepartmentFrom.SelectedValue));
                }

                if (cmbDepartmentTo.Items.Count > 0)
                {
                    objDepTo = objDepartmentDL.Get(Convert.ToInt64(cmbDepartmentTo.SelectedValue));
                }

                if (cmbStoreFrom.Items.Count > 0)
                {
                    objStore = (Store)cmbStoreFrom.SelectedItem;
                }

                if (!ItemCode.Equals("") && !objGRN.GRNNo.Equals("") && objDepTo != null && objDepFrom != null)
                {
                    if (txtQty.Text.Equals(""))
                    {
                        MessageBox.Show(this, "Please enter Valid Quantity for Transfer", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        if (Convert.ToDecimal(txtQty.Text) > Convert.ToDecimal(txtAvailableQty.Text))
                        {
                            MessageBox.Show(this, "Available Quantity is " + txtAvailableQty.Text + ",Transfer quantity cannot be more than available", "Available Quantity Exceed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            objMTN.MTNDepartmentFrom = objDepFrom;
                            objMTN.MTNDepartmentTo   = objDepTo;
                            objMTN.MTNEnterdBy       = CurrentUser.UserEmp;
                            objMTN.MTNStatus         = MTN.Status.Initial;
                            objMTN.MTNType           = MTN.Type.General;
                            objMTN.MTNStore          = objStore;
                            if (cmbMTNType.SelectedItem.Equals("Basic Product"))
                            {
                                objMTN.MTNItemType = MTN.ItemType.Basic_Product;


                                objMTN.MTNNo = objMTNDL.Add(objMTN);

                                if (objMTN.MTNNo > 0)
                                {
                                    objBasicProduct = objBasicProductDL.Get((cmbItem.SelectedValue.ToString()));


                                    objMTNBasic.Batch        = "No";
                                    objMTNBasic.Description  = txtRemarks.Text;
                                    objMTNBasic.BasicProduct = objBasicProduct;
                                    objMTNBasic.MTN          = objMTN;
                                    objMTNBasic.TransferQty  = Convert.ToDecimal(txtQty.Text);
                                    objMTNBasic.UnitRate     = Convert.ToDecimal(txtGRNUnitCost.Text) + Convert.ToDecimal(txtStockHoldingCost.Text);


                                    objMTNBasicProductDL.Add(objMTNBasic);

                                    MessageBox.Show(this, "Successfully Saved, MTN No is " + objMTN.MTNNo, "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else if (cmbMTNType.SelectedItem.Equals("Material"))
                            {
                                objMTN.MTNItemType = MTN.ItemType.Material;


                                objMTN.MTNNo = objMTNDL.Add(objMTN);

                                if (objMTN.MTNNo > 0)
                                {
                                    objMaterial = objMaterialDL.Get(cmbItem.SelectedValue.ToString());


                                    objMTNMat.Batch       = "No";
                                    objMTNMat.Description = txtRemarks.Text;
                                    objMTNMat.Material    = objMaterial;
                                    objMTNMat.MTN         = objMTN;
                                    objMTNMat.TransferQty = Convert.ToDecimal(txtQty.Text);
                                    objMTNMat.UnitRate    = Convert.ToDecimal(txtGRNUnitCost.Text) + Convert.ToDecimal(txtStockHoldingCost.Text);


                                    objMTNMaterialDL.Add(objMTNMat);

                                    MessageBox.Show(this, "Successfully Saved, MTN No is " + objMTN.MTNNo, "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else if (cmbMTNType.SelectedItem.Equals("Finish Product"))
                            {
                                objMTN.MTNItemType = MTN.ItemType.Finish_Product;


                                objMTN.MTNNo = objMTNDL.Add(objMTN);

                                if (objMTN.MTNNo > 0)
                                {
                                    objFinishProduct = objFinishProductDL.Get((cmbItem.SelectedValue.ToString()));


                                    objMTNFinish.Batch         = "No";
                                    objMTNFinish.Description   = txtRemarks.Text;
                                    objMTNFinish.FinishProduct = objFinishProduct;
                                    objMTNFinish.MTN           = objMTN;
                                    objMTNFinish.TransferQty   = Convert.ToDecimal(txtQty.Text);
                                    objMTNFinish.UnitRate      = Convert.ToDecimal(txtGRNUnitCost.Text) + Convert.ToDecimal(txtStockHoldingCost.Text);


                                    objMTNFinisProductDL.Add(objMTNFinish);

                                    MessageBox.Show(this, "Successfully Saved, MTN No is " + objMTN.MTNNo, "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, "Please check Item, Department and GRN that you selected", "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }