Ejemplo n.º 1
0
    private void btnAdd_Click(object sender, EventArgs e)
    {
        if (Validations())
        {
            try
            {
                DataTable dtStockAdjust;
                dataAcess.BeginTransaction();
                if (dataAcess.getDBCommand().Transaction == null)
                {
                    dataAcess.SetDBTransaction();
                }
                dtStockAdjust = manageProduct.InsertStockAdjusmentMaster(dtp.Value, Convert.ToInt32(cmbWarehouse.SelectedValue), txtRemarks.Text, MainForm.User_Id, DateTime.Now, "", dataAcess);
                if (dtStockAdjust.Rows.Count > 0)
                {
                    StockAdjusmentId = Convert.ToInt32(dtStockAdjust.Rows[0]["Id"]);
                    //txtAdjustNo.Text = dtStockAdjust.Rows[0]["AdjustmentNo"].ToString();
                }
                else
                {
                    throw new Exception("Adjustment Refrence not found");
                }
                if (StockAdjusmentId > 0)
                {
                    for (int i = 0; i < dset.Tables["AdjustmentDetail"].Rows.Count; i++)
                    {
                        DataRow drDetail = dset.Tables["AdjustmentDetail"].Rows[i];
                        if (drDetail.RowState != DataRowState.Deleted)
                        {
                            int DetailId = manageProduct.InsertUpdateStockAdjustmentDetail(Convert.ToInt32(drDetail["AdjustDetailId"]), StockAdjusmentId,
                                                                                           Convert.ToInt32(drDetail["ProductId"]), "Stock", Convert.ToInt32(cmbWarehouse.SelectedValue),
                                                                                           Convert.ToDecimal(drDetail["Qty"]), drDetail["FlagIO"].ToString(), dataAcess);

                            manageProduct.InsertProductLedger(Convert.ToInt32(drDetail["ProductId"]), dtp.Value, dtStockAdjust.Rows[0]["AdjustmentNo"].ToString(), DetailId, drDetail["FlagIO"].ToString(), Convert.ToDecimal(drDetail["Qty"]), 0, 0, 0, 0, 0, MainForm.User_Id, DateTime.Now.Date, "", "",
                                                              null, "Adjustment from Adjustment Form", Convert.ToInt32(cmbWarehouse.SelectedValue), -1, "", dataAcess);
                        }
                    }
                    dataAcess.TransCommit();
                    MessageBox.Show("Stock Adjusment Record Insert Sucessfully", "Record Saved Successful.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearFeilds();
                }
                else
                {
                    throw new Exception("Master Data does Not Insert.");
                }
            }
            catch (SqlException sqlex)
            {
                dataAcess.TransRollback();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                dataAcess.ConnectionClose();
            }
        }
    }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                DataTable dtVoucher = null;
                try
                {
                    int CashCOAId, VendorCOAId = -1;
                    VendorCOAId = manageAccount.GetCOAIdByCode(txtAccCode.Text); // yeh Creadit hoga yani "C"
                    CashCOAId   = manageAccount.GetCOAIdByCode(txtCashAcc.Text); //yeh Debit hoga yani "D"

                    if (VendorCOAId <= 0 || CashCOAId <= 0)
                    {
                        MessageBox.Show("Error While Save Cash Payment. Account Code or Cash Account is missing", "Account Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (VendorCOAId == CashCOAId)
                    {
                        MessageBox.Show("Account Code and Cash Account should not be Same.", "Same Account Restriction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    dataAcess.BeginTransaction();
                    if (dataAcess.getDBCommand().Transaction == null)
                    {
                        dataAcess.SetDBTransaction();
                    }
                    dtVoucher       = VM.InsertVoucharMaster(Convert.ToDateTime(dtpVoucher.Value), "CP", "K", txtNaration.Text, Convert.ToDecimal(txtAmount.Text), Convert.ToDecimal(txtAmount.Text), MainForm.User_Id, DateTime.Now.Date, "", dataAcess);
                    VoucherMasterId = Convert.ToInt32(dtVoucher.Rows[0]["VoucherMasterId"]);
                    VM.InsertVoucherDetail(VoucherMasterId, "", "", CashCOAId, txtCashAcc.Text, "D", Convert.ToDecimal(txtAmount.Text), txtRemarks.Text, dataAcess);
                    VM.InsertVoucherDetail(VoucherMasterId, "", "", VendorCOAId, txtAccCode.Text, "C", Convert.ToDecimal(txtAmount.Text), txtRemarks.Text, dataAcess);

                    //int VendorId = Vendor.GetVendorIdByCode(txtVendorCode.Text);
                    //Vendor.InsertVendorLedger(VendorId, Convert.ToDateTime(dtpVoucher.Value), "", -1, 0, dtVoucher.Rows[0]["VoucherNumber"].ToString(), VoucherMasterId, Convert.ToDecimal(txtAmount.Text), dataAcess);
                    dataAcess.TransCommit();
                    MessageBox.Show("Cash Payment Record Insert Successfull", "Record Inserted.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //if (VoucherMasterId > 0)
                    //{
                    //    LoadVoucher(VoucherMasterId);
                    //}
                    ClearFeilds();
                }
                catch (SqlException sqlex)
                {
                    dataAcess.TransRollback();
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    dataAcess.ConnectionClose();
                }
            }
        }
Ejemplo n.º 3
0
    private void btnAdd_Click(object sender, EventArgs e)
    {
        if (Validation())
        {
            DataTable dtVoucher = new DataTable();
            try
            {
                int BankCOAId, VendorCOAId = -1;
                VendorCOAId = manageAccount.GetCOAIdByCode(txtAccCode.Text); // yeh Debit hoga yani "C"
                BankCOAId   = manageAccount.GetCOAIdByCode(txtBankAcc.Text); //yeh Credit hoga yani "D"

                if (VendorCOAId <= 0 || BankCOAId <= 0)
                {
                    MessageBox.Show("Error While Save Bank Payment. Vendor Account or Bank Account is missing", "Account Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (VendorCOAId == BankCOAId)
                {
                    MessageBox.Show("Vendor Account and Bank Account should not be Same.", "Same Account Restriction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                dataAcess.BeginTransaction();
                if (dataAcess.getDBCommand().Transaction == null)
                {
                    dataAcess.SetDBTransaction();
                }

                dtVoucher       = VM.InsertVoucharMaster(dtpVoucher.Value, "BP", "K", txtNaration.Text, Convert.ToDecimal(txtAmount.Text), Convert.ToDecimal(txtAmount.Text), MainForm.User_Id, DateTime.Now.Date, "", dataAcess);
                VoucherMasterId = Convert.ToInt32(dtVoucher.Rows[0]["VoucherMasterId"]);
                VM.InsertVoucherDetail(VoucherMasterId, "", txtVendorCode.Text, VendorCOAId, txtAccCode.Text, "C", Convert.ToDecimal(txtAmount.Text), "", dataAcess);
                VM.InsertVoucherDetail(VoucherMasterId, "", "", BankCOAId, txtBankAcc.Text, "D", Convert.ToDecimal(txtAmount.Text), "", dataAcess);
                manageBank.InsertUpdateBankVoucherDetail(BankVoucherDetailId, dtpVoucher.Value, string.Empty, txtVendorCode.Text, BankId, BankACId, Convert.ToDecimal(txtAmount.Text), dtpCheque.Value, (cmbChequeBank.SelectedIndex > 0 ? Convert.ToInt32(cmbChequeBank.SelectedValue) : -1), txtChequeNumber.Text, "Payment", VoucherMasterId, "BP", "", DateTime.Now, dataAcess);
                dataAcess.TransCommit();
                MessageBox.Show("Bank Payment Insert Successfull", "Record Inserted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearFeilds();
            }
            catch (SqlException sqlex)
            {
                dataAcess.TransRollback();
                MessageBox.Show(sqlex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dataAcess.ConnectionClose();
            }
        }
    }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (Validations())
            {
                try
                {
                    DataTable dtReqMaster;
                    dataAcess.BeginTransaction();
                    if (dataAcess.getDBCommand().Transaction == null)
                    {
                        dataAcess.SetDBTransaction();
                    }

                    dtReqMaster = manageRequisition.InsertStockRequisition(Convert.ToDateTime(dtp.Value.ToString()), txtOrderByCode.Text, txtDeliveredByCode.Text, Convert.ToInt32(cmbFWarehouse.SelectedValue), Convert.ToInt32(cmbTWarehouse.SelectedValue), txtRemarks.Text, "H", false, false, "Requisition", dataAcess);
                    if (dtReqMaster.Rows.Count > 0)
                    {
                        StockReqMasterId = Convert.ToInt32(dtReqMaster.Rows[0]["Id"]);
                        for (int i = 0; i < dset.Tables["REQDetail"].Rows.Count; i++)
                        {
                            DataRow drDetail = dset.Tables["REQDetail"].Rows[i];
                            int     DetailId = manageRequisition.InsertUpdateRequisitionDetail(Convert.ToInt32(drDetail["StockReqDetailId"]), StockReqMasterId, Convert.ToInt32(drDetail["ProductId"]), Convert.ToDecimal(drDetail["Qty"]), dataAcess);
                        }
                        dataAcess.TransCommit();

                        if (MessageBox.Show("Requisition " + dtReqMaster.Rows[0]["StockReqNo"].ToString() + " has Saved." + Environment.NewLine + " Do you want to Print. ", "Requisition Saved Successful.", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            //PrintInvoice();
                        }
                        //yahan clear kerna zarori hai warna at a time approve ka form open oh and app approved hojye toh yeh koi change na ker sky.
                        ClearFeilds();
                        //ButtonRights(false);
                        //LoadInvoice();
                    }
                    else
                    {
                        throw new Exception("Master Data does Not Insert.");
                    }
                }
                catch (SqlException sqlex)
                {
                    dataAcess.TransRollback();
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    dataAcess.ConnectionClose();
                }
            }
        }
Ejemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (Validations())
            {
                try
                {
                    dataAcess.BeginTransaction();
                    if (dataAcess.getDBCommand().Transaction == null)
                    {
                        dataAcess.SetDBTransaction();
                    }

                    ProductOpeningBalanceId = manageProduct.InsertProductOpeningBalance(Convert.ToDateTime(dtp.Value.ToString()), false, 0, "", "H", txtRemarks.Text, MainForm.User_Id, DateTime.Now, "", dataAcess);
                    if (ProductOpeningBalanceId > 0)
                    {
                        for (int i = 0; i < dset.Tables["ProductOpeningDetail"].Rows.Count; i++)
                        {
                            DataRow drDetail = dset.Tables["ProductOpeningDetail"].Rows[i];
                            int     DetailId = manageProduct.InsertUpdateProductOpeningDetail(Convert.ToInt32(drDetail["ProdOpenBalDetailId"]), ProductOpeningBalanceId, Convert.ToInt32(drDetail["ProductId"]), "Stock", "Opening", Convert.ToInt32(cmbWarehouse.SelectedValue), Convert.ToDecimal(drDetail["OpeningBalance"]), 0, null, dataAcess);
                        }
                        dataAcess.TransCommit();
                        MessageBox.Show("Product Opening Balance Record Insert Sucessfully", "Record Saved Successful.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ClearFeilds();
                    }
                    else
                    {
                        throw new Exception("Master Data does Not Insert.");
                    }
                }
                catch (SqlException sqlex)
                {
                    dataAcess.TransRollback();
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    dataAcess.ConnectionClose();
                }
            }
        }
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (Validation())
     {
         try
         {
             dataAcess.BeginTransaction();
             if (dataAcess.getDBCommand().Transaction == null)
             {
                 dataAcess.SetDBTransaction();
             }
             foreach (int id in DeletedIds)
             {
                 manageProduct.DeleteFormulaConfigByConfigId(id, dataAcess);
             }
             foreach (DataRow dr in dsMain.Tables["FormulaConfig"].Rows)
             {
                 if (dr.RowState != DataRowState.Deleted)
                 {
                     manageProduct.InsertUpdateFormulaConfig(Convert.ToInt32(dr["FormulaConfigId"]), Convert.ToInt32(dr["WarehouseId"]), Convert.ToInt32(dr["ProductId"]), Convert.ToInt32(dr["UnitId"]), Convert.ToInt32(dr["WarehouseSequance"]), Convert.ToInt32(dr["ProductSequance"]), dataAcess);
                 }
             }
             dataAcess.TransCommit();
             MessageBox.Show("Product Formula Config Update Successfull", "Record Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
             DeletedIds = new List <int>();
             setupGrip();
         }
         catch (SqlException sqlex)
         {
             MessageBox.Show(sqlex.Message);
             dataAcess.TransRollback();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             dataAcess.ConnectionClose();
         }
     }
 }
Ejemplo n.º 7
0
    private void btnAdd_Click(object sender, EventArgs e)
    {
        if (Validation())
        {
            DataTable dtVoucher = new DataTable();
            try
            {
                dataAcess.BeginTransaction();
                if (dataAcess.getDBCommand().Transaction == null)
                {
                    dataAcess.SetDBTransaction();
                }
                VoucherMasterId = Convert.ToInt32(VM.InsertVoucharMaster(Convert.ToDateTime(dtpVoucher.Value), this.VoucherType, "H", txtNaration.Text, Convert.ToDecimal(txtTotalDebit.Text), Convert.ToDecimal(txtTotalCredit.Text), MainForm.User_Id, DateTime.Now.Date, "", dataAcess).Rows[0]["VoucherMasterId"]);
                foreach (DataRow dr in dsMain.Tables["VoucherDetail"].Rows)
                {
                    VM.InsertVoucherDetail(VoucherMasterId, "", "", Convert.ToInt32(dr["COAId"]), dr["AccountCode"].ToString(), dr["FlagDC"].ToString(), Convert.ToDecimal(dr["Amount"]), dr["Remarks"].ToString(), dataAcess);
                }
                if (this.VoucherType == "CR" || this.VoucherType == "CP")
                {
                    //agr Cash Receipt , ya Cash Payment hoga tog BillNo and Bill Date wala kaam kry ga warna nh.
                    manageBank.InsertUpdateBankVoucherDetail(BankVoucherDetailId, dtpVoucher.Value, string.Empty, string.Empty, -1, -1, 0, DateTime.Now, -1, "", ((this.VoucherType == "CR") ? "Receipt" : "Payment"), VoucherMasterId, this.VoucherType, txtBillNo.Text, dtpBillDate.Value, dataAcess);
                }
                dataAcess.TransCommit();

                MessageBox.Show("Voucher Insert Successfull", "Record Inserted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearFeilds();
            }
            catch (SqlException sqlex)
            {
                dataAcess.TransRollback();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dataAcess.ConnectionClose();
            }
        }
    }
Ejemplo n.º 8
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (Validation())
     {
         try
         {
             ProcessingManager manageProcessing = new ProcessingManager();
             DataTable         dtWTMaster       = new DataTable();
             int EmployeeId = manageEmployee.GetEmployeeIdByCode(txtEmployeeCode.Text);
             if (EmployeeId < 0)
             {
                 MessageBox.Show("Employee does not found.", "Employee Identity not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             int ProductId = -1;
             if (!string.IsNullOrEmpty(txtPCode.Text))
             {
                 ProductId = manageProduct.GetProductIdByCode(txtPCode.Text);
             }
             dataAcess.BeginTransaction();
             if (dataAcess.getDBCommand().Transaction == null)
             {
                 dataAcess.SetDBTransaction();
             }
             dtWTMaster = managewarehouse.InsertWTMaster(EmployeeId, Convert.ToInt32(cmbFWarehouse.SelectedValue), Convert.ToInt32(cmbTWarehouse.SelectedValue), dtpDate.Value, txtSONo.Text, ProductId, txtRemarks.Text, false, false, "H", MainForm.User_Id, DateTime.Now, "", chkProcess.Checked, (string.IsNullOrEmpty(txtProcessQty.Text) ? 0 : Convert.ToDecimal(txtProcessQty.Text)), txtBatchNo.Text, dataAcess);
             if (dtWTMaster.Rows.Count == 0)
             {
                 MessageBox.Show("Department Transfer Insert Error", "Can not Insert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 throw new Exception();
             }
             else
             {
                 WTMasterId = Convert.ToInt32(dtWTMaster.Rows[0]["Id"]);
             }
             foreach (DataRow dr in dsMain.Tables["WTDetail"].Rows)
             {
                 int DetailId = managewarehouse.InsertUpdateWTDetail(Convert.ToInt32(dr["WTDetailId"]), WTMasterId, Convert.ToInt32(dr["ProductId"]), "H", "Stock", "", "Stock", Convert.ToDecimal(dr["QtyToTransfer"]), MainForm.User_Id, DateTime.Now, "", dataAcess);
                 manageProduct.InsertProductLedger(Convert.ToInt32(dr["ProductId"]), dtpDate.Value, dtWTMaster.Rows[0]["TransferNo"].ToString(), DetailId, "O", Convert.ToDecimal(dr["QtyToTransfer"]), 0, 0, 0, 0, 0, MainForm.User_Id, DateTime.Now.Date, "", "", null, "Transfer Out from Warehouse Transfer", Convert.ToInt32(cmbFWarehouse.SelectedValue), -1, "", dataAcess);
                 manageProduct.InsertProductLedger(Convert.ToInt32(dr["ProductId"]), dtpDate.Value, dtWTMaster.Rows[0]["TransferNo"].ToString(), DetailId, "I", Convert.ToDecimal(dr["QtyToTransfer"]), 0, 0, 0, 0, 0, MainForm.User_Id, DateTime.Now.Date, "", "", null, " Transfer Inn from Warehouse Transfer ", Convert.ToInt32(cmbTWarehouse.SelectedValue), -1, "", dataAcess);
             }
             if (chkProcess.Checked)
             {
                 manageProcessing.InsertUpdateProductionLedger(Convert.ToInt32(cmbTWarehouse.SelectedValue), ProductId, -1, txtSONo.Text, dtpDate.Value, txtWTCode.Text,
                                                               WTMasterId, "I", (string.IsNullOrEmpty(txtProcessQty.Text.ToString()) ? 0 : Convert.ToDecimal(txtProcessQty.Text)), -1, "Entry From Department Transfer", false, dataAcess);
             }
             dataAcess.TransCommit();
             MessageBox.Show("Warehouse Transfer Insert Successfull", "Record Inserted", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ButtonRights(false);
             ClearFeilds();
         }
         catch (SqlException sqlex)
         {
             MessageBox.Show(sqlex.Message);
             dataAcess.TransRollback();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             dataAcess.ConnectionClose();
         }
     }
 }