Ejemplo n.º 1
0
 private void DeletePOB()
 {
     if (string.IsNullOrEmpty(txtPOBId.Text))
     {
         return;
     }
     try
     {
         dataAcess.BeginTransaction();
         manageProduct.DeleteProductOpeningBalanceMaster(ProductOpeningBalanceId, dataAcess);
         dataAcess.TransCommit();
         MessageBox.Show("Product Opening  " + txtPOBId.Text + " is Deleted.", "Product Opening Delete Successful.", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ClearFeilds();
     }
     catch (SqlException sqlex)
     {
         dataAcess.TransRollback();
     }
     catch (Exception ex)
     {
     }
     finally
     {
         dataAcess.ConnectionClose();
     }
 }
Ejemplo n.º 2
0
 private void DeleteRequisition()
 {
     if (string.IsNullOrEmpty(txtRequisitionNo.Text))
     {
         return;
     }
     try
     {
         dataAcess.BeginTransaction();
         manageRequisition.DeleteRequisitionMaster(StockReqMasterId, dataAcess);
         dataAcess.TransCommit();
         MessageBox.Show("Requisition " + txtRequisitionNo.Text + " is Deleted.", "Requisition Delete Successful.", MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnClear_Click(null, null);
     }
     catch (SqlException sqlex)
     {
         dataAcess.TransRollback();
     }
     catch (Exception ex)
     {
     }
     finally
     {
         dataAcess.ConnectionClose();
     }
 }
Ejemplo n.º 3
0
 private void DeleteStockAdjustment()
 {
     if (string.IsNullOrEmpty(txtAdjustNo.Text))
     {
         return;
     }
     try
     {
         dataAcess.BeginTransaction();
         //hum pehele ProductLedger se Clear kry gy than again insert.
         manageProduct.DeleteProductLedgerByTransNo(txtAdjustNo.Text, true, dataAcess);
         manageProduct.DeleteAdjustmentMaster(StockAdjusmentId, dataAcess);
         dataAcess.TransCommit();
         MessageBox.Show("Stock Adjustment  " + txtAdjustNo.Text + " is Deleted.", "Adjustment Delete Successful.", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ClearFeilds();
     }
     catch (SqlException sqlex)
     {
         dataAcess.TransRollback();
     }
     catch (Exception ex)
     {
     }
     finally
     {
         dataAcess.ConnectionClose();
     }
 }
Ejemplo n.º 4
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.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                GenrateBarcode();
                if (string.IsNullOrEmpty(txtBarcode.Text))
                {
                    MessageBox.Show("SKU Code does not found.", "SKU Code Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                Image  productImage = null;
                byte[] pictureimage = null;
                if (!IsPictureUploaded)
                {
                    productImage = null;
                }
                else
                {
                    productImage = pbitem.Image;
                    pictureimage = imageToByteArray(pbitem.Image);
                }
                try
                {
                    dataAcess.BeginTransaction();
                    ProductId = InsertProduct(txtProductName.Text, (string.IsNullOrEmpty(txtCostPrice.Text) ? 0 : Convert.ToDecimal(txtCostPrice.Text)), Convert.ToInt32(cmbProductCatagory.SelectedValue), Convert.ToInt32(cmbProductType.SelectedValue),
                                              Convert.ToInt32(cmbColor.SelectedValue), Convert.ToInt32(cmbSize.SelectedValue), Convert.ToInt32(cmbUnit.SelectedValue), cmbNature.SelectedValue.ToString(),
                                              (string.IsNullOrEmpty(txtRetailPrice.Text) ? 0 : Convert.ToDecimal(txtRetailPrice.Text)),
                                              (string.IsNullOrEmpty(txtProfitMargin.Text) ? 0 : Convert.ToDecimal(txtProfitMargin.Text)),
                                              (string.IsNullOrEmpty(txtDiscPerc.Text) ? 0 : Convert.ToDecimal(txtDiscPerc.Text)),
                                              txtBarcode.Text,
                                              (productImage == null ? null : ImageToBase64(productImage, System.Drawing.Imaging.ImageFormat.Jpeg)), txtReportName.Text, Convert.ToInt32(cmbSubCategory.SelectedValue), chkNotification.Checked, (pictureimage == null ? null : pictureimage), dataAcess);
                    dataAcess.TransCommit();
                    MessageBox.Show("Product Insert Succesfull", "Product Insterted", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    ClearFeilds();
                    if (ProductId > 0)
                    {
                        LoadProduct(ProductId);
                    }
                }
                catch (SqlException sqlex)
                {
                    dataAcess.TransRollback();
                    MessageBox.Show(sqlex.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    dataAcess.ConnectionClose();
                }
            }
        }
Ejemplo n.º 6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                DataTable dtVoucher = new DataTable();
                try
                {
                    int BankCOAId, CustomerCOAId = -1;
                    CustomerCOAId = manageAccount.GetCOAIdByCode(txtAccCode.Text); // yeh Debit hoga yani "D"
                    BankCOAId     = manageAccount.GetCOAIdByCode(txtBankAcc.Text); //yeh Credit hoga yani "C"

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

                    if (CustomerCOAId == BankCOAId)
                    {
                        MessageBox.Show("Customer 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, "BR", "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, txtCustomerCode.Text, "", CustomerCOAId, txtAccCode.Text, "D", Convert.ToDecimal(txtAmount.Text), "", dataAcess);
                    VM.InsertVoucherDetail(VoucherMasterId, "", "", BankCOAId, txtBankAcc.Text, "C", Convert.ToDecimal(txtAmount.Text), "", dataAcess);
                    manageBank.InsertUpdateBankVoucherDetail(BankVoucherDetailId, dtpVoucher.Value, txtCustomerCode.Text, string.Empty, BankId, BankACId, Convert.ToDecimal(txtAmount.Text), dtpCheque.Value, (cmbChequeBank.SelectedIndex > 0 ? Convert.ToInt32(cmbChequeBank.SelectedValue) : -1), txtChequeNumber.Text, "Receipt", VoucherMasterId, "BR", "", DateTime.Now, dataAcess);
                    dataAcess.TransCommit();
                    MessageBox.Show("Bank Receipt 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.º 7
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Validations())
            {
                try
                {
                    int PolicyId = -1;
                    dataAcess.BeginTransaction();
                    managePolicy.InsertUpdateTimeAttendancePolicy(ref PolicyId, txtPolicyCode.Text, "-1", "-1", (string.IsNullOrEmpty(txtCasualLeave.Text) ? 0 : Convert.ToInt32(txtCasualLeave.Text)), (string.IsNullOrEmpty(txtSickLeave.Text) ? 0 : Convert.ToInt32(txtSickLeave.Text)),
                                                                  (string.IsNullOrEmpty(txtHalfDayStartTime.Text) ? 0 : Convert.ToInt32(txtHalfDayStartTime.Text)), (string.IsNullOrEmpty(txtOverTimeRate.Text) ? 0 : Convert.ToInt32(txtOverTimeRate.Text)), "", 0, 0, 0,
                                                                  DutyTimeON.Value, DutyTimeOFF.Value, BeginAttTime.Value, EndAttTime.Value, (string.IsNullOrEmpty(txtOffDayDutyRate.Text) ? 0 : Convert.ToInt32(txtOffDayDutyRate.Text)), (string.IsNullOrEmpty(txtGraceTime.Text) ? 0 : Convert.ToInt32(txtGraceTime.Text)),
                                                                  (string.IsNullOrEmpty(txtLateAfter.Text) ? 0 : Convert.ToInt32(txtLateAfter.Text)), (string.IsNullOrEmpty(txtDeductionAfterLate.Text) ? 0 : Convert.ToInt32(txtDeductionAfterLate.Text)), dataAcess);
                    dataAcess.TransCommit();

                    MessageBox.Show("Time Attendance Policy Save Sucessfully", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FillTimeAttendancePolicy();
                }
                catch (SqlException sqlex)
                {
                    dataAcess.TransRollback();
                    MessageBox.Show(sqlex.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                finally
                {
                    dataAcess.ConnectionClose();
                }
            }
        }
Ejemplo n.º 8
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.º 9
0
    private void DeleteVoucher(int VoucherMasterId)
    {
        try
        {
            dataAcess.BeginTransaction();
            manageBank.DeleteBankVoucherDetailByVoucherMasterId(VoucherMasterId, dataAcess);
            VM.DeleteVoucharMaster(VoucherMasterId, dataAcess);
            dataAcess.TransCommit();
            MessageBox.Show("Voucher Record Delete Successfull.", "Record Deleted.", MessageBoxButtons.OK, MessageBoxIcon.Information);
            ClearFeilds();
        }
        catch (SqlException sqlex)
        {
            dataAcess.TransRollback();
        }

        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Error To Delete Voucher", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
Ejemplo n.º 10
0
 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.º 11
0
 private void PostVoucher()
 {
     try
     {
         dataAcess.BeginTransaction();
         int count   = dtVocherDetail.Select("IsSelect = 1").Length;
         int current = 0;
         foreach (DataRow dr in dtVocherDetail.Rows)
         {
             if (Convert.ToBoolean(dr["IsSelect"]))
             {
                 if (!manageVoucher.PostVoucher(dr["VoucherNumber"].ToString(), dataAcess))
                 {
                     throw new Exception("Data Not Post on Voucher No :" + dr["VoucherNumber"].ToString());
                 }
                 current++;
                 pgBar.Value = current / count * 100;
             }
         }
         dataAcess.TransCommit();
         MessageBox.Show("Record Posting Sucessfully.", "Record Posted", MessageBoxButtons.OK, MessageBoxIcon.Information);
         button1_Click(null, null);
     }
     catch (SqlException sqlex)
     {
         dataAcess.TransRollback();
         MessageBox.Show(sqlex.Message);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         dataAcess.ConnectionClose();
         pgBar.Value = 0;
     }
 }
Ejemplo n.º 12
0
        private bool ImportExcelData(string strFilePath)
        {
            bool      result       = true;
            string    sSheetName   = null;
            string    sConnection  = null;
            DataTable dtTablesList = new DataTable();


            OleDbCommand    oleExcelCommand = new OleDbCommand();
            OleDbDataReader oleExcelReader;
            OleDbConnection oleExcelConnection = new OleDbConnection();
            DataTable       dtExcelData        = new DataTable();
            DataTable       dtExcelDataFinal   = new DataTable();

            Smartworks.DAL dataAccess = new Smartworks.DAL();

            string extension = Path.GetExtension(strFilePath);

            switch (extension)
            {
            case ".xls":
                //sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePath + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'";
                sConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strFilePath + ";Extended Properties=Excel 12.0;";
                break;

            case ".xlsx":
                sConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strFilePath + ";Extended Properties='Excel 12.0;HDR=Yes;IMEX=1;'";
                break;

            default:
                sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePath + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'";
                break;
            }
            //String constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePath + ";Extended Properties='Excel 8.0;HDR=YES;';";
            // sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePath + ";Extended Properties='Excel 8.0;HDR=YES;';";
            oleExcelConnection = new OleDbConnection(sConnection);
            try
            {
                oleExcelConnection.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "File does not read.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            dtTablesList = oleExcelConnection.GetSchema("Tables");
            int SheetIndex = 0;

            foreach (DataRow drSheet in dtTablesList.Rows)
            {
                SheetIndex = SheetIndex + 1;
                sSheetName = drSheet["TABLE_NAME"].ToString();
                if (!sSheetName.Contains("$"))
                {
                    continue;
                }
                //dtTablesList.Clear();
                //dtTablesList.Dispose();

                if (!string.IsNullOrEmpty(sSheetName))
                {
                    oleExcelCommand             = oleExcelConnection.CreateCommand();
                    oleExcelCommand.CommandText = "Select * From [" + sSheetName + "]";
                    oleExcelCommand.CommandType = CommandType.Text;
                    oleExcelReader = oleExcelCommand.ExecuteReader();
                    dtExcelData.Load(oleExcelReader, LoadOption.PreserveChanges);
                    oleExcelReader.Close();
                }

                if (SheetIndex == dtTablesList.Rows.Count)
                {
                    oleExcelConnection.Close();
                }
                if (dtExcelData.Rows.Count > 0)
                {
                    //if (dtExcelData.Columns.Count > 10 || dtExcelData.Columns.Count < 10)
                    //{
                    //    MessageBox.Show("File Format does not match. Make sure your format is as per Sample.", "Format does not match", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //    oleExcelConnection.Close();
                    //    result = false;
                    //    return result;
                    //}


                    //dtExcelData.Rows.RemoveAt(0);
                    /* yeh New format file hai */
                    dtExcelData.Columns[0].ColumnName = "ItemName";
                    dtExcelData.Columns[1].ColumnName = "CategoryName";

                    if (dtExcelDataFinal.Columns.Count == 0)
                    {
                        dtExcelDataFinal = dtExcelData.Clone();
                    }

                    foreach (DataRow dtRow in dtExcelData.Rows)
                    {
                        dtExcelDataFinal.ImportRow(dtRow);
                    }
                }
            }

            if (dtExcelDataFinal.Columns.Count > 0)
            {
                if (dtExcelDataFinal.Rows.Count > 0)
                {
                    int index = 0;
                    try
                    {
                        dataAccess.BeginTransaction();
                        for (int i = 0; i <= dtExcelDataFinal.Rows.Count - 1; i++)
                        {
                            index = i;
                            DataRow drImportRow = dtExcelDataFinal.Rows[i];
                            if (!string.IsNullOrEmpty(drImportRow["ItemName"].ToString()))
                            {
                                Smartworks.ColumnField[] importCustomer = new Smartworks.ColumnField[2];
                                importCustomer[0] = new Smartworks.ColumnField("@ItemName", drImportRow["ItemName"].ToString().Trim());
                                importCustomer[1] = new Smartworks.ColumnField("@CategoryName", drImportRow["CategoryName"].ToString().Trim());

                                dataAccess.ExecuteStoredProcedure("sp_ImportProduct", importCustomer);
                            }
                        }
                        dataAccess.TransCommit();
                        // dataAccess.TransRollback();
                    }
                    catch (SqlException sqlex)
                    {
                        dataAccess.TransRollback();
                        dataAccess.ConnectionClose();
                        //Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Error!!.. File Date not Import.');", true);
                        MessageBox.Show("Error!!.. File Data not Import", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        result = false;
                        return(result);
                    }
                    catch (Exception ex)
                    {
                        dataAccess.ConnectionClose();
                        //Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Error!!.. File Date not Import.');", true);
                        MessageBox.Show("Error!!.. File Data not Import", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        result = false;
                        return(result);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 13
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();
         }
     }
 }