Пример #1
0
 private void dtpDate_Validated(object sender, EventArgs e)
 {
     if (m_lRegTransId == 0)
     {
         int iTypeId = 0;
         if (optStatusType.SelectedIndex == 0)
         {
             iTypeId = 18;
         }
         else if (optStatusType.SelectedIndex == 1)
         {
             iTypeId = 19;
         }
         else if (optStatusType.SelectedIndex == 2)
         {
             iTypeId = 20;
         }
         if (oVType.PeriodWise == true)
         {
             oVType        = new BsfGlobal.VoucherType();
             oVType        = BsfGlobal.GetVoucherNo(iTypeId, Convert.ToDateTime(dtpDate.Text), 0, 0);
             txtRefNo.Text = oVType.VoucherNo;
         }
     }
 }
Пример #2
0
 public frmRegTrans()
 {
     InitializeComponent();
     m_oRegister  = new Vendor.BusinessLayer.RegisterBL();
     m_oRegUpdate = new Vendor.BusinessLayer.RegUpdateBL();
     oVType       = new BsfGlobal.VoucherType();
 }
Пример #3
0
        private void UpdateRegNo()
        {
            oVType = new BsfGlobal.VoucherType();
            //oVType = BsfGlobal.GetVoucherNo(17, Convert.ToDateTime(dtpDate.Text), 0, 0);
            oVType = BsfGlobal.GetVoucherNo(17, Convert.ToDateTime(dtpDate.Value), 0, 0);
            if (oVType.GenType == true)
            {
                if (m_lRegisterId == 0)
                {
                    txtRegNo.Text = oVType.VoucherNo;
                }
                txtRegNo.Enabled = false;
            }

            else
            {
                txtRegNo.Enabled = true;
            }

            //dtType = new DataTable();
            //dtType = m_oType.GetTypeSetup(1);
            //if (dtType.Rows.Count > 0)
            //{
            //    if (Convert.ToBoolean(dtType.Rows[0]["GenType"].ToString()) == true)
            //    {
            //        txtRegNo.Enabled = false;
            //        if (m_lRegisterId == 0) { txtRegNo.Text = GetRegNo(); }
            //    }
            //    else { txtRegNo.Enabled = true; }
            //}
        }
Пример #4
0
        private void UpdateRegNo()
        {
            int iTypeId = 0;

            if (optStatusType.SelectedIndex == 0)
            {
                iTypeId = 18;
            }
            else if (optStatusType.SelectedIndex == 1)
            {
                iTypeId = 19;
            }
            else if (optStatusType.SelectedIndex == 2)
            {
                iTypeId = 20;
            }

            oVType = new BsfGlobal.VoucherType();
            oVType = BsfGlobal.GetVoucherNo(iTypeId, Convert.ToDateTime(dtpDate.Text), 0, 0);
            if (oVType.GenType == true)
            {
                if (m_lRegTransId == 0)
                {
                    txtRefNo.Text = oVType.VoucherNo;
                }
                txtRefNo.Enabled = false;
            }

            else
            {
                txtRefNo.Enabled = true;
            }
        }
Пример #5
0
        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            gridViewReceipt.FocusedRowHandle = gridViewReceipt.FocusedRowHandle + 1;

            if (dateReceipt.Text.Trim() == "")
            {
                MessageBox.Show("Provide Receipt Date", "CRM", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                dateReceipt.Focus();
                return;
            }

            else if (Convert.ToInt32(cboCostCentre.EditValue) == -1)
            {
                MessageBox.Show("Select CostCentre Name", "CRM", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                cboCostCentre.Focus();
                return;
            }

            textAmt.EditValue = CommFun.IsNullCheck(gridViewReceipt.Columns["CurrentAmount"].SummaryText, CommFun.datatypes.vartypenumeric);

            if (Convert.ToDecimal(textAmt.EditValue) <= 0)
            {
                MessageBox.Show("Receipt Amount Should be greater than 0"); return;
            }

            if (ReceiptId == 0)
            {
                if (oVType.GenType == true)
                {
                    oVType             = new BsfGlobal.VoucherType();
                    oVType             = BsfGlobal.GetVoucherNo(26, Convert.ToDateTime(dateReceipt.EditValue), 0, 0);
                    textReceiptNo.Text = oVType.VoucherNo;
                }
            }

            else
            {
                if (oVType.PeriodWise == true)
                {
                    oVType = new BsfGlobal.VoucherType();
                    if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(dateReceipt.EditValue)) == true)
                    {
                        oVType = BsfGlobal.GetVoucherNo(26, Convert.ToDateTime(dateReceipt.EditValue), 0, 0);
                    }
                }
            }

            UpdateReceipt();
            if (ReceiptId == 0)
            {
                ClearEntries();
            }
            else
            {
                Close();
            }
        }
Пример #6
0
        public void UpdateTenant()
        {
            try
            {
                oTtBO = new TenantDetBO();
                TenantDetBO.TenantId     = m_iTenantId;
                TenantDetBO.TenantName   = CommFun.IsNullCheck(txtBrName.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.Address1     = CommFun.IsNullCheck(txtAdd1.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.Address2     = CommFun.IsNullCheck(txtAdd2.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.City         = Convert.ToInt32(CommFun.IsNullCheck(lookUpCity.EditValue, CommFun.datatypes.vartypenumeric));
                TenantDetBO.State        = Convert.ToInt32(CommFun.IsNullCheck(txtState.Tag, CommFun.datatypes.vartypenumeric));
                TenantDetBO.Country      = Convert.ToInt32(CommFun.IsNullCheck(txtCountry.Tag, CommFun.datatypes.vartypenumeric));
                TenantDetBO.Pincode      = CommFun.IsNullCheck(txtPin.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.Mobile       = CommFun.IsNullCheck(txtMobile.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.PhoneRes     = CommFun.IsNullCheck(txtPhoneRes.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.Email        = CommFun.IsNullCheck(txtEmail.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.EmpPlace     = CommFun.IsNullCheck(textEmployment.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.Designation  = CommFun.IsNullCheck(txtjob.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.OffAddress   = CommFun.IsNullCheck(txtOfficeAdd.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.OffPhone     = CommFun.IsNullCheck(txtOfficePh.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.OffEmail     = CommFun.IsNullCheck(txtOfficeEmail.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.Commands     = CommFun.IsNullCheck(txtCmd.Text, CommFun.datatypes.vartypestring).ToString();
                TenantDetBO.CostCentreId = Convert.ToInt32(CommFun.IsNullCheck(lookUpPro.EditValue, CommFun.datatypes.vartypenumeric));
                TenantDetBO.BlockId      = Convert.ToInt32(CommFun.IsNullCheck(lookUpBlock.EditValue, CommFun.datatypes.vartypenumeric));
                TenantDetBO.FlatId       = Convert.ToInt32(CommFun.IsNullCheck(lookUpUnit.EditValue, CommFun.datatypes.vartypenumeric));
                TenantDetBO.TransDate    = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtCompDate.EditValue, CommFun.datatypes.VarTypeDate));
                TenantDetBO.RefNo        = CommFun.IsNullCheck(txtRefNo.Text, CommFun.datatypes.vartypestring).ToString();

                if (m_iTenantId == 0)
                {
                    bSuccess = TenantDetBL.InsertTenantDetails();
                    BsfGlobal.UpdateMaxNo(26, oVType, 0, 0);
                }
                else
                {
                    if (Convert.ToDateTime(ComplaintDetBO.TransDate) != Convert.ToDateTime(dtCompDate.EditValue))
                    {
                        oVType = new BsfGlobal.VoucherType();
                        if (oVType.PeriodWise == true)
                        {
                            if (BsfGlobal.CheckPeriodChange(Convert.ToDateTime(TenantDetBO.TransDate), Convert.ToDateTime(dtCompDate.EditValue)) == true)
                            {
                                oVType        = BsfGlobal.GetVoucherNo(26, Convert.ToDateTime(dtCompDate.EditValue), 0, 0);
                                txtRefNo.Text = oVType.VoucherNo;
                                BsfGlobal.UpdateMaxNo(26, oVType, 0, 0);
                            }
                        }
                    }
                    bSuccess = TenantDetBL.UpdateTenantDetails();
                }
            }
            catch (Exception ex)
            {
                BsfGlobal.CustomException(ex.Message, ex.StackTrace);
            }
        }
Пример #7
0
 private void GetVoucherNo()
 {
     oVType = new BsfGlobal.VoucherType();
     oVType = BsfGlobal.GetVoucherNo(10, Convert.ToDateTime(DEDate.EditValue), 0, 0);
     if (oVType.GenType == true)
     {
         txtRefNo.Text = oVType.VoucherNo;
         BsfGlobal.UpdateMaxNo(10, oVType, 0, 0);
         txtRefNo.ForeColor = Color.Black;
     }
 }
Пример #8
0
 private void dtpDate_Validated(object sender, EventArgs e)
 {
     if (m_lRegisterId == 0)
     {
         if (oVType.PeriodWise == true)
         {
             oVType        = new BsfGlobal.VoucherType();
             oVType        = BsfGlobal.GetVoucherNo(17, Convert.ToDateTime(dtpDate.Value), 0, 0);
             txtRegNo.Text = oVType.VoucherNo;
         }
     }
 }
Пример #9
0
        public void UpdateReceipt()
        {
            try
            {
                oRptBO = new PMSReceiptDetailBO();
                PMSReceiptDetailBO.ReceiptId    = ReceiptId;
                PMSReceiptDetailBO.ReceiptDate  = String.Format("{0:dd-MMM-yyyy}", dateReceipt.EditValue);                                                    //dateReceipt
                PMSReceiptDetailBO.ReceiptNo    = CommFun.IsNullCheck(textReceiptNo.Text, CommFun.datatypes.vartypestring).ToString();                        //textReceiptNo
                PMSReceiptDetailBO.ChequeNo     = CommFun.IsNullCheck(textChequeNo.Text, CommFun.datatypes.vartypestring).ToString();                         //textChequeNo
                PMSReceiptDetailBO.ChequeDate   = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dateCheque.EditValue, CommFun.datatypes.VarTypeDate)); // String.Format("{0:dd-MMM-yyyy}", dateCheque.Text);// dateCheque
                PMSReceiptDetailBO.BankName     = CommFun.IsNullCheck(textBankName.Text, CommFun.datatypes.vartypestring).ToString();                         //textBankName
                PMSReceiptDetailBO.CostCentreId = Convert.ToInt32(CommFun.IsNullCheck(cboCostCentre.EditValue, CommFun.datatypes.vartypenumeric));
                PMSReceiptDetailBO.FlatId       = Convert.ToInt32(CommFun.IsNullCheck(cboFlatNo.EditValue, CommFun.datatypes.vartypenumeric));
                PMSReceiptDetailBO.PaymentMode  = CommFun.IsNullCheck(cboMode.EditValue, CommFun.datatypes.vartypestring).ToString();
                PMSReceiptDetailBO.Amount       = Convert.ToDecimal(CommFun.IsNullCheck(gridViewReceipt.Columns["CurrentAmount"].SummaryText, CommFun.datatypes.vartypenumeric));//textAmt
                PMSReceiptDetailBO.Narration    = CommFun.IsNullCheck(txtNarration.Text, CommFun.datatypes.vartypestring).ToString();


                if (ReceiptId == 0)
                {
                    PMSReceiptBL.InsertReceipt(oRptBO, dtReceipt);
                    //ReceiptDetailBL.InsertReceiptDetails(oRptBO, dtReceipt, m_sBussinessType, dtRecp, dtInfo, dtReceiptType, dtQualifier, m_tQualAbs);
                    //CommFun.InsertLog(DateTime.Now, "Receipt Register-Add", "N", "Add ExtraItem Register", BsfGlobal.g_lUserId, 0, m_iCCId, 0, BsfGlobal.g_sCRMDBName);
                    BsfGlobal.UpdateMaxNo(26, oVType, 0, 0);
                }
                else
                {
                    if (Convert.ToDateTime(PMSReceiptDetailBO.ReceiptDate) != Convert.ToDateTime(dateReceipt.EditValue))
                    {
                        oVType = new BsfGlobal.VoucherType();
                        if (oVType.PeriodWise == true)
                        {
                            if (BsfGlobal.CheckPeriodChange(Convert.ToDateTime(PMSReceiptDetailBO.ReceiptDate), Convert.ToDateTime(dateReceipt.EditValue)) == true)
                            {
                                oVType             = BsfGlobal.GetVoucherNo(26, Convert.ToDateTime(dateReceipt.EditValue), 0, 0);
                                textReceiptNo.Text = oVType.VoucherNo;
                                BsfGlobal.UpdateMaxNo(26, oVType, 0, 0);
                            }
                        }
                    }
                    PMSReceiptBL.UpdateReceipt(oRptBO, dtReceipt);
                    //ReceiptDetailBL.UpdateReceiptDetails(oRptBO, dtReceipt, m_sBussinessType, dtInfo, dtReceiptType, dtQualifier, m_tQualAbs);
                    //CommFun.InsertLog(DateTime.Now, "Receipt Register-Edit", "E", "Edit ExtraItem Register", BsfGlobal.g_lUserId, 0, m_iCCId, 0, BsfGlobal.g_sCRMDBName);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #10
0
 private void GetVoucherNo()
 {
     oVType = new BsfGlobal.VoucherType();
     oVType = BsfGlobal.GetVoucherNo(26, Convert.ToDateTime(dtCompDate.EditValue), 0, 0);
     if (oVType.GenType == true)
     {
         txtRefNo.Enabled = false;
         txtRefNo.Text    = oVType.VoucherNo;
     }
     else
     {
         txtRefNo.Enabled = true;
     }
 }
Пример #11
0
        public int InsertBillEntries(BillRegister argBReg, List<BillAbstract> argBAbs, List<BillEntry> argBEntry, List<BillLabourTypeTransBO> argBLbrType, List<BillMaterialRecovery> argBMatRec, List<BillIOWTransUpdate> argBIOWTrans, List<BIMeasurementBO> argBIMsrment, List<BillIOWMeasurementBOUpdate> argBIOWMsrment, List<BillFormateTDSNewBO> argBFTDS, DataTable argBLbrTrNew, string argBillType, int argCCId, int argContId, int argBdetId, int argRevId, List<BillWBSTrans> argWBSTrans, List<BillWBSMeasurementTransBO> argWBSMsrTrans, List<DPERegTrans> argDPE, ref bool argUpdate, ref string argRefNo, List<BillAdvanceBO> argAdvance, DataTable dtQtrans, List<BillTurnKeyEntry> argTurnKeyTrans, List<BillLBRResourceTransBO> argLbrRes, DataTable argWOTransQual, List<BillMSteelSelection> oSteelSel, List<BillLSWBSTrans> argLSWBS, bool argInternal, List<BillLabourAdvance> argBLbrAdv, List<BillServiceTaxNewBO> argBFST, DataTable dtLbrAdj, string argDBName, List<BillLSVTrans> argBillLSV, List<BillLSTransBO> argBillLSTrans, DataTable argResQualTran, DataTable argResRateQ, List<LabourTransBO> argItemLbr, List<LabourTransBO> argLabourItem, List<LabourTransBO> argLabourSum, List<BillRetentionBO> argRetention, DataTable argMatAdvance, List<BillVATBO> argVAT)
        {
            #region Variables
            int iBillRegId = 0;
            int iBillTransId = 0;
            int iBillIOWTransId = 0;
            string sCVType = "";
            sCVType = BsfGlobal.GetVoucherType(13);
            SqlConnection conn;
            conn = new SqlConnection();
            conn = BsfGlobal.OpenWPMDB();
            SqlTransaction tran = conn.BeginTransaction();
            string sSql = "";
            string sRefDate = "";
            int iBillWBSTransId = 0;

            BsfGlobal.VoucherType oVType = new BsfGlobal.VoucherType();
            BsfGlobal.VoucherType oVCCType = new BsfGlobal.VoucherType();
            BsfGlobal.VoucherType oVCompanyType = new BsfGlobal.VoucherType();

            #endregion

            try
            {

                sRefDate = String.Format("{0:dd-MMM-yyyy}", argBReg.RefDate);

                oVType = BsfGlobal.GetVoucherNo(13, argBReg.EDate, 0, 0,conn,tran,"I");
                if (oVType.GenType == true)
                {
                    argBReg.VNo = oVType.VoucherNo;
                }
                oVCCType = BsfGlobal.GetVoucherNo(13, argBReg.EDate, 0, argBReg.CostCentreId, conn, tran, "I");
                if (oVCCType.GenType == true)
                {
                    argBReg.CCBVNo = oVCCType.VoucherNo;
                }
                oVCompanyType = BsfGlobal.GetVoucherNo(13, argBReg.EDate, argBReg.CompanyId, 0, conn, tran, "I");
                if (oVCompanyType.GenType == true)
                {
                    argBReg.CompanyBVNo = oVCompanyType.VoucherNo;
                }

                #region Register Insert
                //Insert BillRegister
                SqlCommand Command = new SqlCommand("Insert_BillRegister", conn, tran);
                Command.CommandType = CommandType.StoredProcedure;
                Command.Parameters.Clear();
                Command.Parameters.AddWithValue("@BillRegisterId", argBReg.BillRegisterId);
                Command.Parameters["@BillRegisterId"].Direction = ParameterDirection.Output;
                Command.Parameters.AddWithValue("@Edate", argBReg.EDate);
                Command.Parameters.AddWithValue("@FDate", argBReg.FrmDate);
                Command.Parameters.AddWithValue("@TDate", argBReg.ToDate);
                Command.Parameters.AddWithValue("@VNo", argBReg.VNo);
                Command.Parameters.AddWithValue("@CCBVNo", argBReg.CCBVNo);
                Command.Parameters.AddWithValue("@BillNo", argBReg.BillNo);
                Command.Parameters.AddWithValue("@ContractorID", argBReg.ContractorID);
                Command.Parameters.AddWithValue("@BillType", argBReg.BillType);
                Command.Parameters.AddWithValue("@BillDetID", argBReg.BillDetId);
                Command.Parameters.AddWithValue("@BillAmount", argBReg.BillAmount);
                Command.Parameters.AddWithValue("@Narration", argBReg.Narration);
                Command.Parameters.AddWithValue("@CostCentreId", argBReg.CostCentreId);
                Command.Parameters.AddWithValue("@LRoundAmt", argBReg.LRoundAmt);
                Command.Parameters.AddWithValue("@LNetAmt", argBReg.LNetAmt);
                Command.Parameters.AddWithValue("@IOWAmount", argBReg.IOWAmount);
                Command.Parameters.AddWithValue("@LabourAmount", argBReg.LabourAmount);
                Command.Parameters.AddWithValue("@BillUpdateType",Convert.ToChar(argBReg.BillUpdateType));
                Command.Parameters.AddWithValue("@WORegisterId", argBReg.WORegisterID);
                Command.Parameters.AddWithValue("@CreatedUser", argBReg.CreatedUser);
                Command.Parameters.AddWithValue("@CreatedDate", argBReg.CreatedDate);
                Command.Parameters.AddWithValue("@ModifiedUser", argBReg.ModifiedUser);
                Command.Parameters.AddWithValue("@ModifiedDate", argBReg.ModifiedDate);
                Command.Parameters.AddWithValue("@CompanyBVNo", argBReg.CompanyBVNo);

                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                iBillRegId = (int)Command.Parameters["@BillRegisterId"].Value;

                int iReady = 0;
                if (argBReg.Ready == true) { iReady = 1; }

                //Update WorkAccountId in BillRegister
                sSql = "Update BillRegister Set WorkAccountId=" + argBReg.WorkAccountId + ",FormatType='" + argBReg.FormatType + "', " +
                    "CostOption='" + argBReg.CostOption + "',RefDate='" + sRefDate + "',RefNo='" + argBReg.RefNo + "',QualType=" + argBReg.QualType + ",Ready = " + iReady + ",LabourUsedType = '" + argBReg.LabourUsedType + "'  Where BillRegisterId = " + iBillRegId;
                Command = new SqlCommand(sSql, conn, tran);
                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                //Update AdjustAmt in WORegister,for Advance option WOAdvAmt Validation

                //if (argBReg.FormatType == "A")
                //{
                //    sSql = "Update WOPaymentTermsNew Set AdjustAmount=" + argBReg.BillAmount + " where TermsId=" + argTermsId + " and WORegisterId = " + argBReg.WORegisterID;
                //    Command = new SqlCommand(sSql, conn, tran);
                //    Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                //}

                //Delete BillLSTrans Table....
                //sSql = "Delete from  BillLSTrans where BillRegisterID = " + iBillRegId;
                //Command = new SqlCommand(sSql, conn, tran);
                //Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                ////Delete BillLSTrans Table....
                //sSql = "Delete from  BillDPETrans where BillRegisterID = " + iBillRegId;
                //Command = new SqlCommand(sSql, conn, tran);
                //Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                foreach (LabourTransBO objLbr in argLabourSum)
                {
                    sSql = "Insert into BillLabourTrans(BillRegisterId,LabourTypeId,Qty,Rate,Amount,MinRate,AppRate) " +
                           "Values(" + iBillRegId + "," + objLbr.LabourTypeID + "," + objLbr.Qty + "," + objLbr.Rate + "," + objLbr.Amount + "," + objLbr.MinRate + ", " + objLbr.AppRate + ")";
                    Command = new SqlCommand(sSql, conn, tran);
                    Command.ExecuteNonQuery(); Command.Dispose();
                    Command.Dispose();
                }

                if (argBReg.FormatType == "R")
                {
                    foreach (BillRetentionBO obj in argRetention)
                    {
                        if (Convert.ToDecimal(CommFun.IsNullCheck(obj.CurAmount, CommFun.datatypes.vartypenumeric)) > 0)
                        {
                            sSql = "Insert into BillRetentionAdjustment(BillRegisterId,AdjBillRegisterId,Amount) " +
                                   "Values(" + obj.BillRegisterId + "," + iBillRegId + "," + obj.CurAmount + ")";
                            Command = new SqlCommand(sSql, conn, tran); Command.ExecuteNonQuery(); Command.Dispose();
                        }
                    }
                }

                 if (argDPE != null)
                 {
                        List<DPERegTrans> oDpe = argDPE;
                        if (oDpe.Count > 0)
                        {
                            foreach (DPERegTrans objDPE in oDpe)
                            {
                                //Insert BillDPETrans

                                sSql = "Insert into BillDPETrans(BillRegisterID,DPERegisterID,TypeId) Values(" + iBillRegId + "," + objDPE.DPERegId + "," + objDPE.TypeId + ")";
                                Command = new SqlCommand(sSql, conn, tran);
                                Command.ExecuteNonQuery(); Command.Dispose();

                                //Update DPERegister Set ConvertBill=1 Where DPERegisterId ="++""
                                Command = new SqlCommand("Update DPERegister Set ConvertBill=1 Where DPERegisterId =" + objDPE.DPERegId + "", conn, tran);
                                Command.ExecuteNonQuery(); Command.Dispose();

                                //CommFun.ActualCompUpdate(objDPE.DPERegId, argCCId, "D", false, argRevId, argBReg.ContractorID, argDBName,conn, tran);
                            }

                            //InsertRateQ()
                        }
                    }

                //insert AdjustAdvance Amount
                if (argBReg.FormatType == "B")
                {
                    foreach (BillAdvanceBO obj in argAdvance)
                    {
                        decimal AdvAmount = Convert.ToDecimal(CommFun.IsNullCheck(obj.CAmount, CommFun.datatypes.vartypenumeric));
                        if (AdvAmount > 0)
                        {
                            sSql = "Insert Into AdvAdjustment (BillRegisterId,WORegisterId,Amount,RegId,FormatTypeId) " +
                                    "Values (" + iBillRegId + "," + obj.WORegisterId + "," + obj.CAmount + "," +  obj.RegId  + ", " + obj.FormatTypeId +")";
                            Command = new SqlCommand(sSql, conn, tran);
                            Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                            //sSql = "Update WOPaymentTermsNew Set AdjustAmount=AdjustAmount+" + AdvAmount + " " +
                            //        "Where WORegisterId = " + obj.WORegisterId;
                            //Command = new SqlCommand(sSql, conn, tran);
                            //Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                        }
                    }
                }

                foreach (DataRow dRow in argMatAdvance.Rows)
                {
                    sSql = "Insert into BillMaterialAdvanceTrans(BillRegisterId,TypeId,ResourceId,Qty,Rate,Amount,Per,AdvanceAmt) " +
                           "Values(" + iBillRegId + "," + Convert.ToInt32(dRow["TypeId"]) + ", " + Convert.ToInt32(dRow["ResourceId"]) + "," + Convert.ToDecimal(dRow["Qty"]) + "," + Convert.ToDecimal(dRow["Rate"]) + "," + Convert.ToDecimal(dRow["Amount"]) + "," + Convert.ToDecimal(dRow["Per"]) + ", " + Convert.ToDecimal(dRow["AdvanceAmt"]) + ")";
                    Command = new SqlCommand(sSql, conn, tran);
                    Command.ExecuteNonQuery(); Command.Dispose();
                }

                foreach (BillLSTransBO obj in argBillLSTrans)
                {
                    sSql = "Insert into BillLSTrans(LabourStrengthID,BillRegisterID,TypeId) " +
                           "Values(" + obj.LabourStrengthID + "," + iBillRegId + ", " + obj.TypeId + ")";
                    Command = new SqlCommand(sSql, conn, tran);
                    Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                    sSql = "Update LabourStrengthMaster Set ConvertBill=1 Where LabourStrengthID  = " + obj.LabourStrengthID;
                    Command = new SqlCommand(sSql, conn, tran);
                    Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                }

                //Insert BillTypeTrans
                //for (int p = 0; p < argBillType.Count; p++)
                //{
                //    sSql="Insert Into BillTypeTrans (BillRegisterId,BillType) values (" + iBillRegId + ",'" + argBillType[p].ToString() + "')";
                //    Command = new SqlCommand(sSql, conn, tran);
                //    Command.ExecuteNonQuery(); Command.Dispose();
                //}
                #endregion

                #region Insert BillLabours

                //Insert BillLabourTrans

                //List<BillLabourTrans> argBLbrTrNew-BillLabourTrans
                //for (int u = 0; u < argLbrTrnNew.Rows.Count; u++)
                //{
                //    Command = new SqlCommand("Insert_BillLabourTrans", conn, tran);
                //    Command.CommandType = CommandType.StoredProcedure;
                //    Command.Parameters.Clear();
                //    Command.Parameters.AddWithValue("@BillRegisterId", iBillRegId);
                //    Command.Parameters.AddWithValue("@LabourTypeId", argLbrTrnNew.Rows[u]["TypeId"].ToString());
                //    Command.Parameters.AddWithValue("@Qty", argLbrTrnNew.Rows[u]["Qty"].ToString());
                //    Command.Parameters.AddWithValue("@Rate", argLbrTrnNew.Rows[u]["Rate"].ToString());
                //    Command.Parameters.AddWithValue("@Amount", argLbrTrnNew.Rows[u]["Amount"].ToString());
                //    Command.Parameters.AddWithValue("@MinRate", argLbrTrnNew.Rows[u]["MinWage"].ToString());
                //    Command.Parameters.AddWithValue("@AppRate", argLbrTrnNew.Rows[u]["AppRate"].ToString());

                //    Command.ExecuteNonQuery(); Command.Dispose();
                //}

                //Insert LabourBillTrans

                //List<LabourBillTrans> argLbrTrnNew -Wages Format
                for (int u = 0; u <argBLbrTrNew.Rows.Count;u++)
                {
                    Command = new SqlCommand("Insert_LabourBillTrans", conn, tran);
                    Command.CommandType = CommandType.StoredProcedure;
                    Command.Parameters.Clear();
                    Command.Parameters.AddWithValue("@BillRegisterId", iBillRegId);
                    Command.Parameters.AddWithValue("@TypeId", argBLbrTrNew.Rows[u]["TypeId"].ToString());
                    Command.Parameters.AddWithValue("@Amount", argBLbrTrNew.Rows[u]["Amount"].ToString());
                    Command.Parameters.AddWithValue("@Formula", argBLbrTrNew.Rows[u]["Formula"].ToString());

                    Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                }

                #endregion

                #region Qualifiers

                //Bill Qualifier

                if (dtQtrans != null)
                {
                    for (int q = 0; q < dtQtrans.Rows.Count; q++)
                    {
                        sSql = "Insert Into BillRateQ (BillRegisterID,QualifierId,Expression,ExpPer,Add_Less_Flag,SurCharge,EDCess,Amount,ExpValue,ExpPerValue,SurValue,EDValue,HEDCess,HEDValue,NetPer) " +
                                 " Values (" + iBillRegId + "," + Convert.ToInt32(CommFun.IsNullCheck(dtQtrans.Rows[q]["QualifierId"], CommFun.datatypes.vartypenumeric)) + ",'" + dtQtrans.Rows[q]["Expression"] + "', " +
                                  " " + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["ExpPer"], CommFun.datatypes.vartypenumeric)) + ",'" + dtQtrans.Rows[q]["Add_Less_Flag"] + "', " +
                                  " " + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["SurCharge"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["EDCess"], CommFun.datatypes.vartypenumeric)) + ", " +
                                  " " + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["Amount"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["ExpValue"], CommFun.datatypes.vartypenumeric)) + "," +
                                  " " + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["ExpPerValue"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["SurValue"], CommFun.datatypes.vartypenumeric)) + ", " +
                                  " " + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["EDValue"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["HEDPer"], CommFun.datatypes.vartypenumeric)) + ", " +
                                  " " + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["HEDValue"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(dtQtrans.Rows[q]["NetPer"], CommFun.datatypes.vartypenumeric)) + ")";
                        Command = new SqlCommand(sSql, conn, tran);
                        Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                    }
                }

                //if (argWOTransQual != null)
                //{
                //    for (int q = 0; q < argWOTransQual.Rows.Count; q++)
                //    {
                //        sSql = "Insert Into BillRateQ (BillRegisterID,QualifierId,Expression,ExpPer,Add_Less_Flag,SurCharge,EDCess,Amount,ExpValue,ExpPerValue,SurValue,EDValue,TypeId,HEDCess,HEDValue,NetPer) " +
                //                 " Values (" + iBillRegId + "," + Convert.ToInt32(CommFun.IsNullCheck(argWOTransQual.Rows[q]["QualifierId"], CommFun.datatypes.vartypenumeric)) + ",'" + argWOTransQual.Rows[q]["Expression"] + "', " +
                //                  " " + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["ExpPer"], CommFun.datatypes.vartypenumeric)) + ",'" + argWOTransQual.Rows[q]["Add_Less_Flag"] + "', " +
                //                  " " + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["SurCharge"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["EDCess"], CommFun.datatypes.vartypenumeric)) + ", " +
                //                  " " + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["Amount"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["ExpValue"], CommFun.datatypes.vartypenumeric)) + "," +
                //                  " " + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["ExpPerValue"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["SurValue"], CommFun.datatypes.vartypenumeric)) + ", " +
                //                  " " + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["EDValue"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToInt32(CommFun.IsNullCheck(argWOTransQual.Rows[q]["AbsTypeId"], CommFun.datatypes.vartypenumeric)) + "," +
                //                  " " + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["HEDPer"], CommFun.datatypes.vartypenumeric)) + "," + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["HEDValue"], CommFun.datatypes.vartypenumeric)) + ", " +
                //                  " " + Convert.ToDecimal(CommFun.IsNullCheck(argWOTransQual.Rows[q]["NetPer"], CommFun.datatypes.vartypenumeric)) + ")";
                //        Command = new SqlCommand(sSql, conn, tran);
                //        Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                //    }
                //}

                #endregion

                #region BillFormat Trans and IOW

                //Insert BillFormateTrans  List<BillAbstract> argBAbs

                foreach (BillAbstract objAbs in argBAbs)
                {
                    Command = new SqlCommand("Insert_BillFormatTrans", conn, tran);
                    Command.CommandType = CommandType.StoredProcedure;
                    Command.Parameters.Clear();
                    Command.Parameters.AddWithValue("@BillRegisterId", iBillRegId);
                    Command.Parameters.AddWithValue("@TypeId", objAbs.TypeId);
                    Command.Parameters.AddWithValue("@Amount", objAbs.Amount);
                    Command.Parameters.AddWithValue("@AccountId", objAbs.AccountId);
                    Command.Parameters.AddWithValue("@Formula", objAbs.Formula);
                    Command.Parameters.AddWithValue("@Add_Less_Flag", objAbs.Sign);
                    Command.Parameters.AddWithValue("@QualMId", objAbs.QualMId);

                    Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                    //Qualifier TypeId in BillFormatTrans
                    sSql = "Update BillFormatTrans Set QTypeId=" + objAbs.QTypeId + ",FormatType='" + objAbs.BFormatType + "',QualifierId = " + objAbs.QualifierId + ",TaxPercentage = " + objAbs.TaxPer + " Where BillRegisterId=" + iBillRegId + " and TypeId=" + objAbs.TypeId;
                    Command = new SqlCommand(sSql, conn, tran);
                    Command.ExecuteNonQuery(); Command.Dispose();

                    if (objAbs.FormatTypeId == 8)
                    {
                         List<BillVATBO> oVATsel = argVAT.FindAll(delegate(BillVATBO del) { return (del.TypeId == objAbs.TypeId); });
                         if (oVATsel.Count > 0)
                         {
                             foreach (BillVATBO objVAT in oVATsel)
                             {
                                 sSql = "Insert into BillVATTrans(BillRegisterId,TypeId,Expression,ExpValue,VATPer,NetValue) " +
                                        "Values(" + iBillRegId + "," + objAbs.TypeId + ",'" + objVAT.Expression + "'," + objVAT.ExpValue + ", " + objVAT.Per + "," + objVAT.NetTax + ")";
                                 Command = new SqlCommand(sSql, conn, tran);
                                 Command.ExecuteNonQuery(); Command.Dispose();
                             }
                         }
                    }

                    if (objAbs.FormatTypeId==1)
                    {
                        //Insert Bill TurnKey Trans argTurnKeyTrans

                        List<BillTurnKeyEntry> oBTsel = argTurnKeyTrans.FindAll(delegate(BillTurnKeyEntry del) { return (del.BAbsTypeId == objAbs.TypeId); });
                        if (oBTsel.Count > 0)
                        {
                            foreach (BillTurnKeyEntry objBTKTrns in oBTsel)
                            {
                                //if (objBTKTrns.WORegId == 0)
                                //{
                                //    sSql = "Insert INTO BillTurnKeyTrans(BillRegisterId,TypeId,WORegisterId,DPERegisterId,AnalysisId,CumPercentage,CurPercentage,CurAmount,PrevPercentage,CumQty,WOAllotted) " +
                                //        "Values(" + iBillRegId + "," + objBTKTrns.BAbsTypeId + ",0,"+objBTKTrns.DPERegId+"," + objBTKTrns.AnalysisId + "," + objBTKTrns.CumulativeQty + ", " +
                                //        " " + objBTKTrns.CurrentQty + "," + objBTKTrns.CurrentAmount + "," + objBTKTrns.PreviousQty + "," + objBTKTrns.CurrentQty + "," + objBTKTrns.WOQty + ")";
                                //}
                                //else
                                //{
                                //    sSql = "Insert INTO BillTurnKeyTrans(BillRegisterId,TypeId,WORegisterId,DPERegisterId,AnalysisId,CumPercentage,CurPercentage,CurAmount,CumAmount,WOAllotted,PrevPercentage,CumQty) " +
                                //        "Values(" + iBillRegId + "," + objBTKTrns.BAbsTypeId + "," + objBTKTrns.WORegId + ","+objBTKTrns.DPERegId+"," + objBTKTrns.AnalysisId + "," + objBTKTrns.CumulativeQty + ", " +
                                //        " " + objBTKTrns.CurrentQty + "," + objBTKTrns.CurrentAmount + "," + objBTKTrns.CumAmount + "," + objBTKTrns.WOQty + "," + objBTKTrns.PreviousQty + "," + objBTKTrns.CurrentQty + ")";
                                //}

                                sSql = "Insert INTO BillTurnKeyTrans(BillRegisterId,TypeId,WORegisterId,DPERegisterId,AnalysisId,CumPercentage,CurPercentage,CurAmount,CumAmount,WOAllotted,PrevPercentage,CumQty) " +
                                    "Values(" + iBillRegId + "," + objBTKTrns.BAbsTypeId + "," + objBTKTrns.WORegId + ","+objBTKTrns.DPERegId+"," + objBTKTrns.AnalysisId + "," + objBTKTrns.CumulativeQty + ", " +
                                    " " + objBTKTrns.CurrentQty + "," + objBTKTrns.CurrentAmount + "," + objBTKTrns.CumAmount + "," + objBTKTrns.WOQty + "," + objBTKTrns.PreviousQty + "," + objBTKTrns.CurrentQty + ")";

                                Command = new SqlCommand(sSql, conn, tran);
                                Command.ExecuteNonQuery(); Command.Dispose();
                                Command.Dispose();
                            }

                            //TurnKey DPE Trans
                        //    if (argDPE != null)
                        //    {
                        //        List<DPERegTrans> oDpe = argDPE.FindAll(delegate(DPERegTrans del) { return (del.TypeId == objAbs.TypeId); });
                        //        if (oDpe.Count > 0)
                        //        {
                        //            foreach (DPERegTrans objDPE in oDpe)
                        //            {
                        //                //Insert BillDPETrans
                        //                Command = new SqlCommand("Insert_BillDPETrans", conn, tran);
                        //                Command.CommandType = CommandType.StoredProcedure;
                        //                Command.Parameters.Clear();
                        //                Command.Parameters.AddWithValue("@BillRegisterID", iBillRegId);
                        //                Command.Parameters.AddWithValue("@DPERegisterID", objDPE.DPERegId);

                        //                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                        //                //Update DPERegister Set ConvertBill=1 Where DPERegisterId ="++""
                        //                Command = new SqlCommand("Update DPERegister Set ConvertBill=1 Where DPERegisterId =" + objDPE.DPERegId + "", conn, tran);
                        //                Command.ExecuteNonQuery(); Command.Dispose();

                        //                CommFun.ActualCompUpdate(objDPE.DPERegId, argCCId, "D", false, argRevId, argBReg.ContractorID,argDBName, conn, tran);
                        //            }

                        //            //InsertRateQ()
                        //        }
                        //    }
                        }

                        //Insert BillTrans
                        List<BillEntry> osel=argBEntry.FindAll(delegate(BillEntry del){return (del.BAbsTypeId==objAbs.TypeId);});
                        if(osel.Count>0)
                        {
                            foreach (BillEntry objBTrns in osel)
                            {

                                Command = new SqlCommand("Insert_BillTrans", conn, tran);
                                Command.CommandType = CommandType.StoredProcedure;
                                Command.Parameters.Clear();
                                Command.Parameters.AddWithValue("@BillTransID", objBTrns.BillTransId);
                                Command.Parameters["@BillTransID"].Direction = ParameterDirection.Output;
                                Command.Parameters.AddWithValue("@BillRegisterID", iBillRegId);
                                Command.Parameters.AddWithValue("@TypeId", objBTrns.BAbsTypeId);
                                Command.Parameters.AddWithValue("@IOW_ID", objBTrns.IOW_ID);
                                Command.Parameters.AddWithValue("@Comp_ID", objBTrns.ResourceId);
                                Command.Parameters.AddWithValue("@UnitID", objBTrns.Unit);

                                //if (objBTrns.Sign.ToString()=="-")
                                //    Command.Parameters.AddWithValue("@Qty", "-"+objBTrns.Qty.ToString());
                                //else

                                if (objBTrns.Sign.ToString() == "-")
                                {
                                    Command.Parameters.AddWithValue("@Qty", objBTrns.Qty*(-1));
                                    Command.Parameters.AddWithValue("@Amount", objBTrns.Amount * (-1));
                                }
                                else
                                {
                                    Command.Parameters.AddWithValue("@Qty", objBTrns.Qty);
                                    Command.Parameters.AddWithValue("@Amount", objBTrns.Amount);
                                }

                                Command.Parameters.AddWithValue("@Rate", objBTrns.Rate);

                                Command.Parameters.AddWithValue("@AnalysisHeadId", objBTrns.AnalysisHeadId);
                                Command.Parameters.AddWithValue("@BillType", argBReg.BillType);
                                Command.Parameters.AddWithValue("@MType", objBTrns.MType);
                                Command.Parameters.AddWithValue("@FullRate", objBTrns.FullRate);
                                Command.Parameters.AddWithValue("@PerPart", objBTrns.PerPart);
                                Command.Parameters.AddWithValue("@PartRate", objBTrns.PartRate);
                                Command.Parameters.AddWithValue("@MUnitID", objBTrns.MUOM_ID);
                                Command.Parameters.AddWithValue("@UFactor", objBTrns.UFactor);
                                Command.Parameters.AddWithValue("@DetSpec", objBTrns.DetSpec);
                                Command.Parameters.AddWithValue("@WORegisterID", objBTrns.WORegisterID);
                                Command.Parameters.AddWithValue("@RateType", objBTrns.RateType);

                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                                iBillTransId = (int)Command.Parameters["@BillTransID"].Value;

                                if (objBTrns.Type == "A" || objBTrns.Type == "L")
                                {
                                    UpdateLatestRate(conn, tran, 0, objBTrns.ResourceId, argBReg.ContractorID, Convert.ToDecimal(objBTrns.Rate), objBTrns.RateType);
                                }
                                else
                                {
                                    UpdateLatestRate(conn, tran, objBTrns.IOW_ID, 0, argBReg.ContractorID, Convert.ToDecimal(objBTrns.Rate), objBTrns.RateType);
                                }
                                //insert BillItem Labour Trans

                                int rsrceId2 = 0;
                                if (objBTrns.ResourceId == 0) { rsrceId2 = objBTrns.IOW_ID; }
                                else if (objBTrns.IOW_ID == 0) { rsrceId2 = objBTrns.ResourceId; }
                                //List<BillItemLbrStrnthTransBO> oSItmLbrTrns = argBLbrItem.FindAll(delegate(BillItemLbrStrnthTransBO del) { return del.BAbsTypeId == objBTrns.BAbsTypeId && del.ItemTransId == rsrceId2; });
                                //if (oSItmLbrTrns.Count > 0)
                                //{
                                //    foreach (BillItemLbrStrnthTransBO objItem in oSItmLbrTrns)
                                //    {
                                //        Command = new SqlCommand("Insert_BillItemLabourTrans", conn, tran);
                                //        Command.CommandType = CommandType.StoredProcedure;
                                //        Command.Parameters.Clear();
                                //        Command.Parameters.AddWithValue("@BillTransID", iBillTransId);
                                //        Command.Parameters.AddWithValue("@LabourTypeID", objItem.LbrTypeId);
                                //        Command.Parameters.AddWithValue("@Qty", objItem.Qtty);
                                //        Command.Parameters.AddWithValue("@Rate", objItem.Rate);
                                //        Command.Parameters.AddWithValue("@Amount", objItem.Amount);
                                //        Command.Parameters.AddWithValue("@AppRate", objItem.AppRate);
                                //        Command.Parameters.AddWithValue("@MinRate", objItem.MinRate);
                                //        Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                //    }
                                //}

                                List<LabourTransBO> oChk = argLabourItem.FindAll(delegate(LabourTransBO del) { return del.AbsTypeId == objAbs.TypeId && del.RowId == objBTrns.RowId; });

                                foreach (LabourTransBO objLbr in oChk)
                                {
                                    sSql = "Insert into BillItemLabourTrans(BillTransId,LabourTypeId,Qty,Rate,Amount,MinRate,AppRate) " +
                                           "Values(" + iBillTransId + "," + objLbr.LabourTypeID + "," + objLbr.Qty + "," + objLbr.Rate + "," + objLbr.Amount + "," + objLbr.MinRate + ", " + objLbr.AppRate + ")";
                                    Command = new SqlCommand(sSql, conn, tran);
                                    Command.ExecuteNonQuery(); Command.Dispose();
                                    Command.Dispose();
                                }

                                if (objBTrns.Type == "I")
                                {
                                    if (argBReg.QualType == 1)
                                    {
                                        DataView dv;
                                        DataTable dtR = new DataTable();
                                        //IOW Resource Trans
                                        if (argResQualTran != null)
                                        {
                                            if (argResQualTran.Rows.Count > 0)
                                            {
                                                dv = new DataView(argResQualTran);
                                                dv.RowFilter = "WOTransRowId=" + objBTrns.RowId;
                                                dtR = dv.ToTable();
                                            }
                                            else
                                            { dtR.Rows.Clear(); }
                                        }

                                        int iResSel = 0;
                                        for (int l = 0; l < dtR.Rows.Count; l++)
                                        {
                                            if (Convert.ToBoolean(dtR.Rows[l]["Select"]) == true) { iResSel = 1; }

                                            sSql = "Insert Into BillResourceTrans (BillTransId,TypeId,ResourceId,QRate,CoffQty,IOWQty,Amount,NetAmount,IOWId,BillQTypeId,ResSel) " +
                                                    "Values(" + iBillTransId + "," + Convert.ToInt32(dtR.Rows[l]["TypeId"]) + "," + Convert.ToInt32(dtR.Rows[l]["ResourceId"]) + ", " +
                                                    "" + Convert.ToDecimal(dtR.Rows[l]["QRate"]) + "," + Convert.ToDecimal(dtR.Rows[l]["CoffQty"]) + "," + Convert.ToDecimal(dtR.Rows[l]["IOWQty"]) + "," + Convert.ToDecimal(dtR.Rows[l]["WOAmount"]) + "," + Convert.ToDecimal(dtR.Rows[l]["NetAmount"]) + "," + Convert.ToInt32(dtR.Rows[l]["IOWId"]) + "," + Convert.ToInt32(dtR.Rows[l]["WOQTypeId"]) + "," + iResSel + ")";
                                            Command = new SqlCommand(sSql, conn, tran);
                                            Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                                        }
                                        //Insert QTypeTrans
                                        if (argResRateQ != null)
                                        {
                                            if (argResRateQ.Rows.Count > 0)
                                            {
                                                dv = new DataView(argResRateQ);
                                                dv.RowFilter = "TransRowId=" + objBTrns.RowId;
                                                dtR = dv.ToTable();
                                            }
                                            else
                                            {
                                                dtR.Rows.Clear();
                                            }
                                        }

                                        for (int q = 0; q < dtR.Rows.Count; q++)
                                        {
                                            sSql = "Insert Into BillResRate_Q (BillRegisterID,QualifierId,Expression,ExpPer,Add_Less_Flag,SurCharge,EDCess,Amount,ExpValue,ExpPerValue," +
                                                    "SurValue,EDValue,HEDCess,HEDValue,NetPer,QType,BillTransID,ResourceID,TaxablePer,TaxableValue) " +
                                                    " Values (" + iBillRegId + "," + Convert.ToInt32(dtR.Rows[q]["QualifierId"]) + ",'" + dtR.Rows[q]["Expression"].ToString() + "', " +
                                                     " " + Convert.ToDecimal(dtR.Rows[q]["ExpPer"]) + ",'" + dtR.Rows[q]["Add_Less_Flag"].ToString() + "', " +
                                                     " " + Convert.ToDecimal(dtR.Rows[q]["SurCharge"]) + "," + Convert.ToDecimal(dtR.Rows[q]["EDCess"]) + ", " +
                                                     " " + Convert.ToDecimal(dtR.Rows[q]["Amount"]) + "," + Convert.ToDecimal(dtR.Rows[q]["ExpValue"]) + "," +
                                                     " " + Convert.ToDecimal(dtR.Rows[q]["ExpPerValue"]) + "," + Convert.ToDecimal(dtR.Rows[q]["SurValue"]) + ", " +
                                                     " " + Convert.ToDecimal(dtR.Rows[q]["EDValue"]) + "," + Convert.ToDecimal(dtR.Rows[q]["HEDPer"]) + "," +
                                                      " " + Convert.ToDecimal(dtR.Rows[q]["HEDValue"]) + "," + Convert.ToDecimal(dtR.Rows[q]["NetPer"]) + "," +
                                                     " '" + (dtR.Rows[q]["QType"]) + "'," + iBillTransId + ", " +
                                                     " " + Convert.ToInt32(dtR.Rows[q]["ResourceId"]) + "," +
                                                     "  " + Convert.ToDecimal(dtR.Rows[q]["TaxablePer"]) + "," + Convert.ToDecimal(dtR.Rows[q]["TaxableValue"]) + ")";
                                            Command = new SqlCommand(sSql, conn, tran);
                                            Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                        }
                                    }

                                    //if (argBReg.BillType == "I")
                                    //{

                                    //    if (argSplit != "Y")
                                    //    {
                                    //        List<LabourTransBO> lChk = argItemLbr.FindAll(delegate(LabourTransBO del) { return del.AbsTypeId == objAbs.TypeId &&  del.RowId == objBTrns.RowId;});

                                    //        foreach (LabourTransBO objLbr in lChk)
                                    //        {
                                    //            sSql = "Insert into BillItemLabourTrans(BillTransId,LabourTypeId,Qty,Rate,Amount,MinRate,AppRate) " +
                                    //                   "Values(" + iBillTransId + "," + objLbr.LabourTypeID + "," + objLbr.Qty + "," + objLbr.Rate + "," + objLbr.Amount + "," + objLbr.MinRate + ", " + objLbr.AppRate + ")";
                                    //            Command = new SqlCommand(sSql, conn, tran);
                                    //            Command.ExecuteNonQuery(); Command.Dispose();
                                    //            Command.Dispose();
                                    //        }
                                    //    }
                                    //}

                                    //WBSTrans
                                    List<BillWBSTrans> Chk = argWBSTrans.FindAll(delegate(BillWBSTrans del) { return del.TypeId == objAbs.TypeId && del.RowId == objBTrns.RowId; });

                                    if (Chk.Count > 0)
                                    {
                                        foreach (BillWBSTrans objWBS in Chk)
                                        {
                                            if (objWBS.Qty != 0)
                                            {
                                                decimal dWBSQty = objWBS.Qty;
                                                decimal dWBSAmt = objWBS.Amount;

                                                if (objBTrns.Sign.ToString() == "-") { dWBSQty = dWBSQty * (-1); dWBSAmt = dWBSAmt * (-1); }

                                                sSql = "INSERT INTO BillWBSTrans (BillTransId,AnalysisId,Qty,MType,Rate,Amount)  " +
                                                       "VALUES(" + iBillTransId + "," + objWBS.AnalysisHeadId + "," + dWBSQty + "," + objWBS.MType + "," + objWBS.Rate + "," + dWBSAmt + ") Select SCOPE_IDENTITY();";
                                                Command = new SqlCommand(sSql, conn, tran);
                                                iBillWBSTransId = Convert.ToInt32(Command.ExecuteScalar());
                                                Command.Dispose();

                                                List<LabourTransBO> lChk = argItemLbr.FindAll(delegate(LabourTransBO del) { return del.AbsTypeId == objAbs.TypeId && del.RowId == objBTrns.RowId && del.AnalysisId == objWBS.AnalysisHeadId; });
                                                foreach (LabourTransBO objLbr in lChk)
                                                {
                                                    sSql = "Insert into BillWBSLabourTrans(BillWBSTransId,BillTransId,LabourTypeId,Qty,Rate,Amount,MinRate,AppRate,AnalysisId) " +
                                                           "Values(" + iBillWBSTransId + "," + iBillTransId + "," + objLbr.LabourTypeID + "," + objLbr.Qty + "," + objLbr.Rate + "," + objLbr.Amount + "," + objLbr.MinRate + ", " + objLbr.AppRate + "," + objWBS.AnalysisHeadId + ")";
                                                    Command = new SqlCommand(sSql, conn, tran);
                                                    Command.ExecuteNonQuery(); Command.Dispose();
                                                    Command.Dispose();
                                                }

                                                //WBSRow LabourTrans
                                                //List<BillIOWLbrTrans> oIOWLbr = argBIOWLbrTrans.FindAll(delegate(BillIOWLbrTrans del)
                                                //{ return ((del.DPEItemTransId == rsrceId2) && (del.AnalysisId == objWBS.AnalysisHeadId)); });
                                                //if (oIOWLbr.Count > 0)
                                                //{
                                                //    foreach (BillIOWLbrTrans objIOWLbr in oIOWLbr)
                                                //    {
                                                //        Command = new SqlCommand("Insert_BillIOWLabourTrans", conn, tran);
                                                //        Command.CommandType = CommandType.StoredProcedure;
                                                //        Command.Parameters.Clear();
                                                //        Command.Parameters.AddWithValue("@BillIOWTransID", iBillIOWTransId);
                                                //        Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                //        Command.Parameters.AddWithValue("@LabourTypeId", objIOWLbr.LbrTypeId);
                                                //        Command.Parameters.AddWithValue("@Qty", objIOWLbr.Qtty);
                                                //        Command.Parameters.AddWithValue("@Rate", objIOWLbr.Rate);
                                                //        Command.Parameters.AddWithValue("@Amount", objIOWLbr.Amount);
                                                //        Command.Parameters.AddWithValue("@AppRate", objIOWLbr.AppRate);
                                                //        Command.Parameters.AddWithValue("@MinRate", objIOWLbr.MinRate);
                                                //        Command.Parameters.AddWithValue("@AnalysisId", objIOWLbr.AnalId);
                                                //        //AnalysisId

                                                //        Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                //    }
                                                //}

                                                // WBSMeasurementTrans
                                                if (objWBS.MType == 0 || objWBS.MType == 2)
                                                {
                                                    List<BillWBSMeasurementTransBO> wbsMsr = argWBSMsrTrans.FindAll(
                                                        delegate(BillWBSMeasurementTransBO del)
                                                        {
                                                            return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.AHeadId == objWBS.AnalysisHeadId));
                                                        });
                                                    if (wbsMsr.Count > 0)
                                                    {
                                                        foreach (BillWBSMeasurementTransBO objIMsr in wbsMsr)
                                                        {
                                                            Command = new SqlCommand("Insert_BillWBSMeasurment", conn, tran);
                                                            Command.CommandType = CommandType.StoredProcedure;
                                                            Command.Parameters.Clear();
                                                            Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                            Command.Parameters.AddWithValue("@BillIOWTransId", objIMsr.ItemTransId);
                                                            Command.Parameters.AddWithValue("@IOWId", objIMsr.AHeadId);
                                                            Command.Parameters.AddWithValue("@RowId", objIMsr.RowId);
                                                            Command.Parameters.AddWithValue("@SlNo", objIMsr.SlNo);
                                                            Command.Parameters.AddWithValue("@Description", objIMsr.Description);
                                                            Command.Parameters.AddWithValue("@No1", objIMsr.No1);
                                                            Command.Parameters.AddWithValue("@No2", objIMsr.No2);
                                                            Command.Parameters.AddWithValue("@Length", objIMsr.Length);
                                                            Command.Parameters.AddWithValue("@Breadth", objIMsr.Breadth);
                                                            Command.Parameters.AddWithValue("@Depth", objIMsr.Depth);
                                                            Command.Parameters.AddWithValue("@Qty", objIMsr.Qty);

                                                            Command.Parameters.AddWithValue("@Sign", objIMsr.Sign);
                                                            Command.Parameters.AddWithValue("@MBookNO", objIMsr.MBookNO);
                                                            Command.Parameters.AddWithValue("@PageNo", objIMsr.PageNo);
                                                            Command.Parameters.AddWithValue("@LevelNo", objIMsr.LevelNo);
                                                            Command.Parameters.AddWithValue("@ParentID", objIMsr.ParentID);
                                                            Command.Parameters.AddWithValue("@SteelId", objIMsr.SteelId);
                                                            Command.Parameters.AddWithValue("@Factor", objIMsr.Factor);

                                                            if (CommFun.IsNullCheck(objIMsr.FNo1, CommFun.datatypes.vartypestring) != null)
                                                                Command.Parameters.AddWithValue("@FNo1", CommFun.IsNullCheck(objIMsr.FNo1, CommFun.datatypes.vartypestring));
                                                            else
                                                                Command.Parameters.AddWithValue("@FNo1", "");

                                                            if (CommFun.IsNullCheck(objIMsr.FNo2, CommFun.datatypes.vartypestring) != null)
                                                                Command.Parameters.AddWithValue("@FNo2", CommFun.IsNullCheck(objIMsr.FNo2, CommFun.datatypes.vartypestring));
                                                            else
                                                                Command.Parameters.AddWithValue("@FNo2", "");

                                                            if (Convert.ToDecimal(CommFun.IsNullCheck(objIMsr.FLength, CommFun.datatypes.vartypenumeric)) != 0)
                                                                Command.Parameters.AddWithValue("@FLength", CommFun.IsNullCheck(objIMsr.FLength, CommFun.datatypes.vartypestring));
                                                            else
                                                                Command.Parameters.AddWithValue("@FLength", 0);

                                                            if (Convert.ToDecimal(CommFun.IsNullCheck(objIMsr.FBreadth, CommFun.datatypes.vartypenumeric)) != 0)
                                                                Command.Parameters.AddWithValue("@FBreadth", CommFun.IsNullCheck(objIMsr.FBreadth, CommFun.datatypes.vartypestring));
                                                            else
                                                                Command.Parameters.AddWithValue("@FBreadth", 0);

                                                            if (Convert.ToDecimal(CommFun.IsNullCheck(objIMsr.FDepth, CommFun.datatypes.vartypenumeric)) != 0)
                                                                Command.Parameters.AddWithValue("@FDepth", CommFun.IsNullCheck(objIMsr.FDepth, CommFun.datatypes.vartypestring));
                                                            else
                                                                Command.Parameters.AddWithValue("@FDepth", 0);

                                                            Command.Parameters.AddWithValue("@BillType", CommFun.IsNullCheck(objBTrns.Type.ToString(), CommFun.datatypes.vartypestring));

                                                            if (CommFun.IsNullCheck(objIMsr.SubFormula, CommFun.datatypes.vartypestring) != null)
                                                                Command.Parameters.AddWithValue("@SubFormula", CommFun.IsNullCheck(objIMsr.SubFormula, CommFun.datatypes.vartypestring));
                                                            else
                                                                Command.Parameters.AddWithValue("@SubFormula", "");

                                                            if (CommFun.IsNullCheck(objIMsr.WBSWise, CommFun.datatypes.vartypestring) != null)
                                                                Command.Parameters.AddWithValue("@WBSWise", CommFun.IsNullCheck(objIMsr.WBSWise, CommFun.datatypes.vartypestring));
                                                            else
                                                                Command.Parameters.AddWithValue("@WBSWise", "");

                                                            //Command.Parameters.AddWithValue("@FNo1", objIMsr.FNo1);
                                                            //Command.Parameters.AddWithValue("@FNo2", objIMsr.FNo2);
                                                            //Command.Parameters.AddWithValue("@FLength", objIMsr.FLength);
                                                            //Command.Parameters.AddWithValue("@FBreadth", objIMsr.FBreadth);

                                                            //Command.Parameters.AddWithValue("@FDepth", objIMsr.FDepth);
                                                            //Command.Parameters.AddWithValue("@BillType", objIMsr.BillType);
                                                            //Command.Parameters.AddWithValue("@SubFormula", objIMsr.SubFormula);
                                                            //Command.Parameters.AddWithValue("@WBSWise", objIMsr.WBSWise);

                                                            Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                        }
                                                    }
                                                }
                                                else if (objWBS.MType == 1)
                                                {
                                                    List<BillMSteelSelection> ocheckUpdate = oSteelSel.FindAll(
                                                        delegate(BillMSteelSelection sel)
                                                        {
                                                            return sel.TypeId == objAbs.TypeId && sel.AnalId == objWBS.AnalysisHeadId && sel.TransRowId == objBTrns.RowId;
                                                        });
                                                    if (ocheckUpdate.Count > 0)
                                                    {
                                                        foreach (BillMSteelSelection IMsrSel in ocheckUpdate)
                                                        {
                                                            sSql = "Insert INTO BillMSteelSelection(BillTransId,IOW_ID,IOW_Trans_Id,AnalId,SteelId) " +
                                                             " Values(" + iBillTransId + "," + objBTrns.IOW_ID + ",0," + objWBS.AnalysisHeadId + " , " +
                                                             " " + CommFun.IsNullCheck(IMsrSel.SteelId, CommFun.datatypes.vartypenumeric) + ")";
                                                            Command = new SqlCommand(sSql, conn, tran);
                                                            Command.ExecuteNonQuery(); Command.Dispose();
                                                            Command.Dispose();
                                                        }
                                                    }

                                                    List<BillWBSMeasurementTransBO> wbsMsr = argWBSMsrTrans.FindAll(
                                                        delegate(BillWBSMeasurementTransBO del)
                                                        {
                                                            return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.AHeadId == objWBS.AnalysisHeadId));
                                                        });
                                                    if (wbsMsr.Count > 0)
                                                    {
                                                        foreach (BillWBSMeasurementTransBO objIMsr in wbsMsr)
                                                        {
                                                            Command = new SqlCommand("Insert_BillWBSMeasurment", conn, tran);
                                                            Command.CommandType = CommandType.StoredProcedure;
                                                            Command.Parameters.Clear();
                                                            Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                            Command.Parameters.AddWithValue("@BillIOWTransId", objIMsr.ItemTransId);
                                                            Command.Parameters.AddWithValue("@IOWId", objIMsr.AHeadId);
                                                            Command.Parameters.AddWithValue("@RowId", objIMsr.RowId);
                                                            Command.Parameters.AddWithValue("@SlNo", objIMsr.SlNo);
                                                            Command.Parameters.AddWithValue("@Description", objIMsr.Description);
                                                            Command.Parameters.AddWithValue("@No1", objIMsr.No1);
                                                            Command.Parameters.AddWithValue("@No2", objIMsr.No2);
                                                            Command.Parameters.AddWithValue("@Length", objIMsr.Length);
                                                            Command.Parameters.AddWithValue("@Breadth", 0);
                                                            Command.Parameters.AddWithValue("@Depth", objIMsr.Diameter);
                                                            Command.Parameters.AddWithValue("@Qty", objIMsr.Qty);

                                                            Command.Parameters.AddWithValue("@Sign", "");
                                                            Command.Parameters.AddWithValue("@MBookNO", 0);
                                                            Command.Parameters.AddWithValue("@PageNo", 0);
                                                            Command.Parameters.AddWithValue("@LevelNo", 0);
                                                            Command.Parameters.AddWithValue("@ParentID", 0);
                                                            Command.Parameters.AddWithValue("@SteelId", objIMsr.SteelId);
                                                            Command.Parameters.AddWithValue("@Factor", objIMsr.Factor);
                                                            Command.Parameters.AddWithValue("@FNo1", "");
                                                            Command.Parameters.AddWithValue("@FNo2", "");
                                                            Command.Parameters.AddWithValue("@FLength", "");
                                                            Command.Parameters.AddWithValue("@FBreadth", "");

                                                            Command.Parameters.AddWithValue("@FDepth", "");
                                                            Command.Parameters.AddWithValue("@BillType", "");
                                                            Command.Parameters.AddWithValue("@SubFormula", "");
                                                            Command.Parameters.AddWithValue("@WBSWise", objIMsr.WBSWise);

                                                            Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                if(objBTrns.Type.ToString()=="I")
                                {
                                    //Insert Measurment for BillTYpe =I; List<BIMeasurementBO> argBIMsrment

                                    if (objBTrns.MType == 0 || objBTrns.MType == 2)
                                    {
                                        List<BIMeasurementBO> oSBIMsr = argBIMsrment.FindAll(delegate(BIMeasurementBO del) { return del.TypeId == objAbs.TypeId && del.TransRowId == objBTrns.RowId; });

                                        if (oSBIMsr.Count > 0)
                                        {
                                            foreach (BIMeasurementBO objIMsr in oSBIMsr)
                                            {
                                                Command = new SqlCommand("Insert_BillMeasurement", conn, tran);
                                                Command.CommandType = CommandType.StoredProcedure;
                                                Command.Parameters.Clear();
                                                Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                Command.Parameters.AddWithValue("@BillIOWTransId", 0);
                                                Command.Parameters.AddWithValue("@IOWId", objIMsr.IOWId);
                                                Command.Parameters.AddWithValue("@RowId", objIMsr.RowId);
                                                Command.Parameters.AddWithValue("@SlNo", objIMsr.SlNo);
                                                Command.Parameters.AddWithValue("@Description", objIMsr.Description);
                                                Command.Parameters.AddWithValue("@No1", objIMsr.No1);
                                                Command.Parameters.AddWithValue("@No2", objIMsr.No2);
                                                Command.Parameters.AddWithValue("@Length", objIMsr.Length);
                                                Command.Parameters.AddWithValue("@Breadth", objIMsr.Breadth);
                                                Command.Parameters.AddWithValue("@Depth", objIMsr.Depth);
                                                Command.Parameters.AddWithValue("@Qty", objIMsr.Qty);
                                                Command.Parameters.AddWithValue("@Sign", objIMsr.Sign);
                                                Command.Parameters.AddWithValue("@MBookNO", objIMsr.MBookNO);
                                                Command.Parameters.AddWithValue("@PageNo", objIMsr.PageNo);
                                                Command.Parameters.AddWithValue("@LevelNo", objIMsr.LevelNo);
                                                Command.Parameters.AddWithValue("@ParentID", objIMsr.ParentID);
                                                Command.Parameters.AddWithValue("@SteelId", objIMsr.SteelId);
                                                Command.Parameters.AddWithValue("@Factor", objIMsr.Factor);

                                                if (CommFun.IsNullCheck(objIMsr.FNo1, CommFun.datatypes.vartypestring) != null)
                                                    Command.Parameters.AddWithValue("@FNo1", CommFun.IsNullCheck(objIMsr.FNo1, CommFun.datatypes.vartypestring));
                                                else
                                                    Command.Parameters.AddWithValue("@FNo1", "");

                                                if (CommFun.IsNullCheck(objIMsr.FNo2, CommFun.datatypes.vartypestring) != null)
                                                    Command.Parameters.AddWithValue("@FNo2", CommFun.IsNullCheck(objIMsr.FNo2, CommFun.datatypes.vartypestring));
                                                else
                                                    Command.Parameters.AddWithValue("@FNo2", "");

                                                if (Convert.ToDecimal(CommFun.IsNullCheck(objIMsr.FLength, CommFun.datatypes.vartypenumeric)) != 0)
                                                    Command.Parameters.AddWithValue("@FLength", CommFun.IsNullCheck(objIMsr.FLength, CommFun.datatypes.vartypestring));
                                                else
                                                    Command.Parameters.AddWithValue("@FLength", 0);

                                                if (Convert.ToDecimal(CommFun.IsNullCheck(objIMsr.FBreadth, CommFun.datatypes.vartypenumeric)) != 0)
                                                    Command.Parameters.AddWithValue("@FBreadth", CommFun.IsNullCheck(objIMsr.FBreadth, CommFun.datatypes.vartypestring));
                                                else
                                                    Command.Parameters.AddWithValue("@FBreadth", 0);

                                                if (Convert.ToDecimal(CommFun.IsNullCheck(objIMsr.FDepth, CommFun.datatypes.vartypenumeric)) != 0)
                                                    Command.Parameters.AddWithValue("@FDepth", CommFun.IsNullCheck(objIMsr.FDepth, CommFun.datatypes.vartypestring));
                                                else
                                                    Command.Parameters.AddWithValue("@FDepth", 0);

                                                Command.Parameters.AddWithValue("@BillType", CommFun.IsNullCheck(objBTrns.Type.ToString(), CommFun.datatypes.vartypestring));

                                                if (CommFun.IsNullCheck(objIMsr.SubFormula, CommFun.datatypes.vartypestring) != null)
                                                    Command.Parameters.AddWithValue("@SubFormula", CommFun.IsNullCheck(objIMsr.SubFormula, CommFun.datatypes.vartypestring));
                                                else
                                                    Command.Parameters.AddWithValue("@SubFormula", "");

                                                //Command.Parameters.AddWithValue("@FNo1", objIMsr.FNo1);
                                                //Command.Parameters.AddWithValue("@FNo2", objIMsr.FNo2);
                                                //Command.Parameters.AddWithValue("@FLength", objIMsr.FLength);
                                                //Command.Parameters.AddWithValue("@FBreadth", objIMsr.FBreadth);
                                                //Command.Parameters.AddWithValue("@FDepth", objIMsr.FDepth);
                                                //Command.Parameters.AddWithValue("@BillType", objIMsr.BillType);
                                                //Command.Parameters.AddWithValue("@SubFormula", objIMsr.SubFormula);

                                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                            }
                                        }
                                    }
                                    else if (objBTrns.MType == 1)
                                    {
                                        List<BillMSteelSelection> ocheckUpdate = oSteelSel.FindAll(
                                        delegate(BillMSteelSelection sel)
                                        {
                                            return sel.TypeId == objAbs.TypeId && sel.TransRowId == objBTrns.RowId;
                                        });
                                        if (ocheckUpdate.Count > 0)
                                        {
                                            foreach (BillMSteelSelection IMsrSel in ocheckUpdate)
                                            {
                                                sSql = "Insert INTO BillMSteelSelection(BillTransId,IOW_ID,IOW_Trans_Id,AnalId,SteelId) " +
                                                 " Values(" + iBillTransId + "," + IMsrSel.BillResId + ",0,0 , " +
                                                 " " + CommFun.IsNullCheck(IMsrSel.SteelId, CommFun.datatypes.vartypenumeric) + ")";
                                                Command = new SqlCommand(sSql, conn, tran);
                                                Command.ExecuteNonQuery(); Command.Dispose();
                                                Command.Dispose();
                                            }
                                        }

                                        List<BIMeasurementBO> oSBIMsr = argBIMsrment.FindAll(
                                            delegate(BIMeasurementBO del)
                                            { return del.TypeId == objAbs.TypeId && del.TransRowId == objBTrns.RowId; });

                                        if (oSBIMsr.Count > 0)
                                        {
                                            foreach (BIMeasurementBO objIMsr in oSBIMsr)
                                            {
                                                Command = new SqlCommand("Insert_BillMeasurement", conn, tran);
                                                Command.CommandType = CommandType.StoredProcedure;
                                                Command.Parameters.Clear();
                                                Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                Command.Parameters.AddWithValue("@BillIOWTransId", 0);
                                                Command.Parameters.AddWithValue("@IOWId", objIMsr.IOWId);
                                                Command.Parameters.AddWithValue("@RowId", objIMsr.RowId);
                                                Command.Parameters.AddWithValue("@SlNo", objIMsr.SlNo);
                                                Command.Parameters.AddWithValue("@Description", objIMsr.Description);
                                                Command.Parameters.AddWithValue("@No1", objIMsr.No1);
                                                Command.Parameters.AddWithValue("@No2", objIMsr.No2);
                                                Command.Parameters.AddWithValue("@Length", objIMsr.Length);
                                                Command.Parameters.AddWithValue("@Breadth", 0);
                                                Command.Parameters.AddWithValue("@Depth", objIMsr.Diameter);
                                                Command.Parameters.AddWithValue("@Qty", objIMsr.Qty);
                                                Command.Parameters.AddWithValue("@Sign", "");
                                                Command.Parameters.AddWithValue("@MBookNO", 0);
                                                Command.Parameters.AddWithValue("@PageNo", 0);
                                                Command.Parameters.AddWithValue("@LevelNo", 0);
                                                Command.Parameters.AddWithValue("@ParentID", 0);
                                                Command.Parameters.AddWithValue("@SteelId", objIMsr.SteelId);
                                                Command.Parameters.AddWithValue("@Factor", objIMsr.Factor);
                                                Command.Parameters.AddWithValue("@FNo1", "");
                                                Command.Parameters.AddWithValue("@FNo2", "");
                                                Command.Parameters.AddWithValue("@FLength", "");
                                                Command.Parameters.AddWithValue("@FBreadth", "");
                                                Command.Parameters.AddWithValue("@FDepth", "");
                                                Command.Parameters.AddWithValue("@BillType", objIMsr.BillType);
                                                Command.Parameters.AddWithValue("@SubFormula", "");

                                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                            }
                                        }
                                    }

                                }
                                else if(objBTrns.Type.ToString()!="I")
                                {
                                    //Insert BillIOWTrans List<BillIOWTransUpdate> argBIOWTrans
                                    int rsrceId3 = 0;
                                    if (objBTrns.ResourceId == 0) { rsrceId3 = objBTrns.IOW_ID; }
                                    if (objBTrns.IOW_ID == 0) { rsrceId3 = objBTrns.ResourceId; }
                                    int iLbrResTransId = 0;

                                    if (objBTrns.Type.ToString() == "L")
                                    {
                                        List<BillLBRResourceTransBO> oLsel = argLbrRes.FindAll(
                                            delegate(BillLBRResourceTransBO del) { return del.TypeId == objAbs.TypeId && del.RowId == objBTrns.RowId; });
                                        if (oLsel.Count > 0)
                                        {
                                            foreach (BillLBRResourceTransBO objLRes in oLsel)
                                            {
                                                if (objLRes.Qty != 0)
                                                {

                                                    decimal dLQty = objLRes.Qty;
                                                    decimal dLAmt = (objLRes.Qty * objLRes.Rate);

                                                    if (objBTrns.Sign.ToString() == "-") { dLQty = dLQty * (-1); dLAmt = dLAmt * (-1); }

                                                    sSql = "INSERT INTO BillLbrResourceTrans (BillTransId,CompId,LbrResourceId,Qty,Rate,AnalysisType,Amount) " +
                                                            "VALUES(" + iBillTransId + "," + objLRes.ItemTransId + "," + objLRes.LbrResourceId + "," + dLQty + "," + objLRes.Rate + ",'" + objLRes.RateType + "'," + dLAmt + ") Select SCOPE_IDENTITY();";
                                                    Command = new SqlCommand(sSql, conn, tran);
                                                    iLbrResTransId = Convert.ToInt32(Command.ExecuteScalar());
                                                    Command.Dispose();

                                                    // Labour Bill IOW Trans

                                                    List<BillIOWTransUpdate> oSIOW = argBIOWTrans.FindAll(
                                                        delegate(BillIOWTransUpdate del)
                                                        { return del.TypeId == objAbs.TypeId && del.RowId == objBTrns.RowId && del.LbrResourceId == objLRes.LbrResourceId && del.RateType == objLRes.RateType ; });
                                                    if (oSIOW.Count > 0)
                                                    {
                                                        foreach (BillIOWTransUpdate objIOW in oSIOW)
                                                        {
                                                            if (objIOW.Qty != 0)
                                                            {
                                                                decimal dIQty = objIOW.Qty;
                                                                decimal dIAmt = objIOW.Amount;

                                                                if (objBTrns.Sign.ToString() == "-") { dIQty = dIQty * (-1); dIAmt = dIAmt * (-1); }

                                                                Command = new SqlCommand("Insert_BillIOWTrans", conn, tran);
                                                                Command.CommandType = CommandType.StoredProcedure;
                                                                Command.Parameters.Clear();
                                                                Command.Parameters.AddWithValue("@BillIOWTransID", objIOW.BillIOWTransID);
                                                                Command.Parameters["@BillIOWTransID"].Direction = ParameterDirection.Output;
                                                                Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                                Command.Parameters.AddWithValue("@IOW_ID", objIOW.IOW_ID);
                                                                Command.Parameters.AddWithValue("@Qty", dIQty);
                                                                Command.Parameters.AddWithValue("@ClaimType", objIOW.ClaimType);
                                                                Command.Parameters.AddWithValue("@AnalysisHeadId", objIOW.AnalysisHeadID);
                                                                Command.Parameters.AddWithValue("@LbrResTransId", iLbrResTransId);
                                                                Command.Parameters.AddWithValue("@MType", objIOW.MType);
                                                                Command.Parameters.AddWithValue("@MUnitId", objIOW.MUnitId);
                                                                Command.Parameters.AddWithValue("@UFactor", objIOW.UFactor);
                                                                Command.Parameters.AddWithValue("@Rate", objIOW.Rate);
                                                                Command.Parameters.AddWithValue("@Amount", dIAmt);
                                                                Command.Parameters.AddWithValue("@SubIOWId", objIOW.SubIOWID);

                                                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                                                                iBillIOWTransId = (int)Command.Parameters["@BillIOWTransID"].Value;

                                                                //Insert IOWLabourTrans List<BillIOWLabour> argBIOWLbrTrans

                                                                //List<BillIOWLbrTrans> oIOWLbr = argBIOWLbrTrans.FindAll(delegate(BillIOWLbrTrans del) { return ((del.IOWRowId == objIOW.RowId) && (del.BEntryRowId == objBTrns.RowId)); });
                                                                //if (oIOWLbr.Count > 0)
                                                                //{
                                                                //    foreach (BillIOWLbrTrans objIOWLbr in oIOWLbr)
                                                                //    {
                                                                //        Command = new SqlCommand("Insert_BillIOWLabourTrans", conn, tran);
                                                                //        Command.CommandType = CommandType.StoredProcedure;
                                                                //        Command.Parameters.Clear();
                                                                //        Command.Parameters.AddWithValue("@BillIOWTransID", iBillIOWTransId);
                                                                //        Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                                //        Command.Parameters.AddWithValue("@LabourTypeId", objIOWLbr.LbrTypeId);
                                                                //        Command.Parameters.AddWithValue("@Qty", objIOWLbr.Qtty);
                                                                //        Command.Parameters.AddWithValue("@Rate", objIOWLbr.Rate);
                                                                //        Command.Parameters.AddWithValue("@Amount", objIOWLbr.Amount);
                                                                //        Command.Parameters.AddWithValue("@AppRate", objIOWLbr.AppRate);
                                                                //        Command.Parameters.AddWithValue("@MinRate", objIOWLbr.MinRate);
                                                                //        Command.Parameters.AddWithValue("@AnalysisId", 0);

                                                                //        Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                                //    }
                                                                //}

                                                                //Insert BillIOWMeasurement List<BillIOWMeasurementBOUpdate> argBIOWMsrment

                                                                if (objIOW.MType == 0 || objIOW.MType == 2)
                                                                {
                                                                    List<BillIOWMeasurementBOUpdate> oSIOWMsrMnt = argBIOWMsrment.FindAll(
                                                                        delegate(BillIOWMeasurementBOUpdate del)
                                                                        { return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.AnalysisId == objIOW.AnalysisHeadID) && (del.IOWId == objIOW.IOW_ID)); });
                                                                    if (oSIOWMsrMnt.Count > 0)
                                                                    {
                                                                        foreach (BillIOWMeasurementBOUpdate objIOWMsr in oSIOWMsrMnt)
                                                                        {
                                                                            Command = new SqlCommand("Insert_BillMeasurement", conn, tran);
                                                                            Command.CommandType = CommandType.StoredProcedure;
                                                                            Command.Parameters.Clear();
                                                                            Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                                            Command.Parameters.AddWithValue("@BillIOWTransId", iBillIOWTransId);
                                                                            Command.Parameters.AddWithValue("@IOWId", objIOWMsr.IOWId);
                                                                            Command.Parameters.AddWithValue("@RowId", objIOWMsr.BEntryRowId);
                                                                            Command.Parameters.AddWithValue("@SlNo", objIOWMsr.SlNo);
                                                                            Command.Parameters.AddWithValue("@Description", objIOWMsr.Description);
                                                                            Command.Parameters.AddWithValue("@No1", objIOWMsr.No1);
                                                                            Command.Parameters.AddWithValue("@No2", objIOWMsr.No2);
                                                                            Command.Parameters.AddWithValue("@Length", objIOWMsr.Length);
                                                                            Command.Parameters.AddWithValue("@Breadth", objIOWMsr.Breadth);
                                                                            Command.Parameters.AddWithValue("@Depth", objIOWMsr.Depth);
                                                                            Command.Parameters.AddWithValue("@Qty", objIOWMsr.Qty);
                                                                            Command.Parameters.AddWithValue("@Sign", objIOWMsr.Sign);
                                                                            Command.Parameters.AddWithValue("@MBookNO", objIOWMsr.MBookNO);
                                                                            Command.Parameters.AddWithValue("@PageNo", objIOWMsr.PageNo);
                                                                            Command.Parameters.AddWithValue("@LevelNo", objIOWMsr.LevelNo);
                                                                            Command.Parameters.AddWithValue("@ParentID", objIOWMsr.ParentID);
                                                                            Command.Parameters.AddWithValue("@SteelId", objIOWMsr.SteelId);
                                                                            Command.Parameters.AddWithValue("@Factor", objIOWMsr.Factor);

                                                                            if (CommFun.IsNullCheck(objIOWMsr.FNo1, CommFun.datatypes.vartypestring) != null)
                                                                                Command.Parameters.AddWithValue("@FNo1", CommFun.IsNullCheck(objIOWMsr.FNo1, CommFun.datatypes.vartypestring));
                                                                            else
                                                                                Command.Parameters.AddWithValue("@FNo1", "");

                                                                            if (CommFun.IsNullCheck(objIOWMsr.FNo2, CommFun.datatypes.vartypestring) != null)
                                                                                Command.Parameters.AddWithValue("@FNo2", CommFun.IsNullCheck(objIOWMsr.FNo2, CommFun.datatypes.vartypestring));
                                                                            else
                                                                                Command.Parameters.AddWithValue("@FNo2", "");

                                                                            if (Convert.ToDecimal(CommFun.IsNullCheck(objIOWMsr.FLength, CommFun.datatypes.vartypenumeric)) != 0)
                                                                                Command.Parameters.AddWithValue("@FLength", CommFun.IsNullCheck(objIOWMsr.FLength, CommFun.datatypes.vartypestring));
                                                                            else
                                                                                Command.Parameters.AddWithValue("@FLength", 0);

                                                                            if (Convert.ToDecimal(CommFun.IsNullCheck(objIOWMsr.FBreadth, CommFun.datatypes.vartypenumeric)) != 0)
                                                                                Command.Parameters.AddWithValue("@FBreadth", CommFun.IsNullCheck(objIOWMsr.FBreadth, CommFun.datatypes.vartypestring));
                                                                            else
                                                                                Command.Parameters.AddWithValue("@FBreadth", 0);

                                                                            if (Convert.ToDecimal(CommFun.IsNullCheck(objIOWMsr.FDepth, CommFun.datatypes.vartypenumeric)) != 0)
                                                                                Command.Parameters.AddWithValue("@FDepth", CommFun.IsNullCheck(objIOWMsr.FDepth, CommFun.datatypes.vartypestring));
                                                                            else
                                                                                Command.Parameters.AddWithValue("@FDepth", 0);

                                                                            Command.Parameters.AddWithValue("@BillType", CommFun.IsNullCheck(objBTrns.Type.ToString(), CommFun.datatypes.vartypestring));

                                                                            if (CommFun.IsNullCheck(objIOWMsr.SubFormula, CommFun.datatypes.vartypestring) != null)
                                                                                Command.Parameters.AddWithValue("@SubFormula", CommFun.IsNullCheck(objIOWMsr.SubFormula, CommFun.datatypes.vartypestring));
                                                                            else
                                                                                Command.Parameters.AddWithValue("@SubFormula", "");

                                                                            //Command.Parameters.AddWithValue("@FNo1", objIOWMsr.FNo1);
                                                                            //Command.Parameters.AddWithValue("@FNo2", objIOWMsr.FNo2);
                                                                            //Command.Parameters.AddWithValue("@FLength", objIOWMsr.FLength);
                                                                            //Command.Parameters.AddWithValue("@FBreadth", objIOWMsr.FBreadth);
                                                                            //Command.Parameters.AddWithValue("@FDepth", objIOWMsr.FDepth);
                                                                            //Command.Parameters.AddWithValue("@BillType", objIOWMsr.BillType);
                                                                            //Command.Parameters.AddWithValue("@SubFormula", objIOWMsr.SubFormula);

                                                                            Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                                        }
                                                                    }
                                                                }
                                                                else if (objIOW.MType == 1)
                                                                {
                                                                    List<BillMSteelSelection> ocheckUpdate = oSteelSel.FindAll(
                                                                        delegate(BillMSteelSelection del)
                                                                        {
                                                                            return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.AnalId == objIOW.AnalysisHeadID) && (del.IOWId == objIOW.IOW_ID));
                                                                            //if (objIOW.AnalysisHeadID != 0)
                                                                            //    return sel.BillResId == rsrceId3 && sel.IOWId == objIOW.IOW_ID && sel.AnalId == objIOW.AnalysisHeadID && sel.TransRowId == objBTrns.RowId;
                                                                            //else
                                                                            //    return sel.BillResId == rsrceId3 && sel.IOWId == objIOW.IOW_ID && sel.TransRowId == objBTrns.RowId;
                                                                        });

                                                                    if (ocheckUpdate.Count > 0)
                                                                    {
                                                                        foreach (BillMSteelSelection IMsrSel in ocheckUpdate)
                                                                        {
                                                                            sSql = "Insert INTO BillMSteelSelection(BillTransId,IOW_ID,IOW_Trans_Id,AnalId,SteelId) " +
                                                                             " Values(" + iBillTransId + "," + rsrceId3 + "," + objIOW.IOW_ID + "," + objIOW.AnalysisHeadID + " , " +
                                                                             " " + CommFun.IsNullCheck(IMsrSel.SteelId, CommFun.datatypes.vartypenumeric) + ")";
                                                                            Command = new SqlCommand(sSql, conn, tran);
                                                                            Command.ExecuteNonQuery(); Command.Dispose();
                                                                            Command.Dispose();
                                                                        }
                                                                    }

                                                                    List<BillIOWMeasurementBOUpdate> oSIOWMsrMnt = argBIOWMsrment.FindAll(
                                                                        delegate(BillIOWMeasurementBOUpdate del)
                                                                        {
                                                                            return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.LbrResourceId == objLRes.LbrResourceId) && (del.RateType == objLRes.RateType) && (del.AnalysisId == objIOW.AnalysisHeadID) && (del.IOWId == objIOW.IOW_ID));
                                                                        });
                                                                    if (oSIOWMsrMnt.Count > 0)
                                                                    {
                                                                        foreach (BillIOWMeasurementBOUpdate objIOWMsr in oSIOWMsrMnt)
                                                                        {
                                                                            Command = new SqlCommand("Insert_BillMeasurement", conn, tran);
                                                                            Command.CommandType = CommandType.StoredProcedure;
                                                                            Command.Parameters.Clear();
                                                                            Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                                            Command.Parameters.AddWithValue("@BillIOWTransId", iBillIOWTransId);
                                                                            Command.Parameters.AddWithValue("@IOWId", objIOWMsr.IOWId);
                                                                            Command.Parameters.AddWithValue("@RowId", objIOWMsr.BEntryRowId);
                                                                            Command.Parameters.AddWithValue("@SlNo", objIOWMsr.SlNo);
                                                                            Command.Parameters.AddWithValue("@Description", objIOWMsr.Description);
                                                                            Command.Parameters.AddWithValue("@No1", objIOWMsr.No1);
                                                                            Command.Parameters.AddWithValue("@No2", objIOWMsr.No2);
                                                                            Command.Parameters.AddWithValue("@Length", objIOWMsr.Length);
                                                                            Command.Parameters.AddWithValue("@Breadth", 0);
                                                                            Command.Parameters.AddWithValue("@Depth", objIOWMsr.Diameter);
                                                                            Command.Parameters.AddWithValue("@Qty", objIOWMsr.Qty);
                                                                            Command.Parameters.AddWithValue("@Sign", "");
                                                                            Command.Parameters.AddWithValue("@MBookNO", 0);
                                                                            Command.Parameters.AddWithValue("@PageNo", 0);
                                                                            Command.Parameters.AddWithValue("@LevelNo", 0);
                                                                            Command.Parameters.AddWithValue("@ParentID", 0);
                                                                            Command.Parameters.AddWithValue("@SteelId", objIOWMsr.SteelId);
                                                                            Command.Parameters.AddWithValue("@Factor", objIOWMsr.Factor);
                                                                            Command.Parameters.AddWithValue("@FNo1", "");
                                                                            Command.Parameters.AddWithValue("@FNo2", "");
                                                                            Command.Parameters.AddWithValue("@FLength", "");
                                                                            Command.Parameters.AddWithValue("@FBreadth", "");
                                                                            Command.Parameters.AddWithValue("@FDepth", "");
                                                                            Command.Parameters.AddWithValue("@BillType", objIOWMsr.BillType);
                                                                            Command.Parameters.AddWithValue("@SubFormula", "");

                                                                            Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                                        }
                                                                    }
                                                                }

                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else if (objBTrns.Type.ToString() == "A" || objBTrns.Type.ToString() == "S")
                                    {
                                        List<BillIOWTransUpdate> oSIOW = argBIOWTrans.FindAll(delegate(BillIOWTransUpdate del) { return del.RowId == objBTrns.RowId && del.TypeId == objAbs.TypeId; });
                                        if (oSIOW.Count > 0)
                                        {
                                            foreach (BillIOWTransUpdate objIOW in oSIOW)
                                            {
                                                if (objIOW.Qty != 0)
                                                {
                                                    decimal dIQty = objIOW.Qty;
                                                    decimal dIAmt = objIOW.Amount;

                                                    if (objBTrns.Sign.ToString() == "-") { dIQty = dIQty * (-1); dIAmt = dIAmt * (-1); }

                                                    Command = new SqlCommand("Insert_BillIOWTrans", conn, tran);
                                                    Command.CommandType = CommandType.StoredProcedure;
                                                    Command.Parameters.Clear();
                                                    Command.Parameters.AddWithValue("@BillIOWTransID", objIOW.BillIOWTransID);
                                                    Command.Parameters["@BillIOWTransID"].Direction = ParameterDirection.Output;
                                                    Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                    Command.Parameters.AddWithValue("@IOW_ID", objIOW.IOW_ID);
                                                    Command.Parameters.AddWithValue("@Qty", dIQty);
                                                    Command.Parameters.AddWithValue("@ClaimType", objIOW.ClaimType);
                                                    Command.Parameters.AddWithValue("@AnalysisHeadId", objIOW.AnalysisHeadID);
                                                    Command.Parameters.AddWithValue("@LbrResTransId", 0);
                                                    Command.Parameters.AddWithValue("@MType", objIOW.MType);
                                                    Command.Parameters.AddWithValue("@MUnitId", objIOW.MUnitId);
                                                    Command.Parameters.AddWithValue("@UFactor", objIOW.UFactor);
                                                    Command.Parameters.AddWithValue("@Rate", objIOW.Rate);
                                                    Command.Parameters.AddWithValue("@Amount", dIAmt);
                                                    Command.Parameters.AddWithValue("@SubIOWId", objIOW.SubIOWID);

                                                    Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                                                    iBillIOWTransId = (int)Command.Parameters["@BillIOWTransID"].Value;

                                                    List<LabourTransBO> lChk = argItemLbr.FindAll(delegate(LabourTransBO del) { return del.AbsTypeId == objAbs.TypeId && del.RowId == objBTrns.RowId && del.AnalysisId == objIOW.AnalysisHeadID && del.IOWId == objIOW.IOW_ID; });
                                                    foreach (LabourTransBO objLbr in lChk)
                                                    {
                                                        sSql = "Insert into BillIOWLabourTrans(BillIOWTransID,BillTransId,LabourTypeId,Qty,Rate,Amount,MinRate,AppRate,AnalysisId,IOWId) " +
                                                               "Values(" + iBillIOWTransId + "," + iBillTransId + "," + objLbr.LabourTypeID + "," + objLbr.Qty + "," + objLbr.Rate + "," + objLbr.Amount + "," + objLbr.MinRate + ", " + objLbr.AppRate + "," + objIOW.AnalysisHeadID + "," + objIOW.IOW_ID + ")";
                                                        Command = new SqlCommand(sSql, conn, tran);
                                                        Command.ExecuteNonQuery(); Command.Dispose();
                                                        Command.Dispose();
                                                    }

                                                    //Insert IOWLabourTrans List<BillIOWLabour> argBIOWLbrTrans
                                                    //List<BillIOWLbrTrans> oIOWLbr = argBIOWLbrTrans.FindAll(delegate(BillIOWLbrTrans del)
                                                    //{
                                                    //    if (objIOW.AnalysisHeadID != 0)
                                                    //        return ((del.DPEItemTransId == rsrceId3) && (del.IOW_ID == objIOW.IOW_ID) && (del.AnalysisId == objIOW.AnalysisHeadID));
                                                    //    else
                                                    //        return ((del.DPEItemTransId == rsrceId3) && (del.IOW_ID == objIOW.IOW_ID));
                                                    //});
                                                    //if (oIOWLbr.Count > 0)
                                                    //{
                                                    //    foreach (BillIOWLbrTrans objIOWLbr in oIOWLbr)
                                                    //    {
                                                    //        Command = new SqlCommand("Insert_BillIOWLabourTrans", conn, tran);
                                                    //        Command.CommandType = CommandType.StoredProcedure;
                                                    //        Command.Parameters.Clear();
                                                    //        Command.Parameters.AddWithValue("@BillIOWTransID", iBillIOWTransId);
                                                    //        Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                    //        Command.Parameters.AddWithValue("@LabourTypeId", objIOWLbr.LbrTypeId);
                                                    //        Command.Parameters.AddWithValue("@Qty", objIOWLbr.Qtty);
                                                    //        Command.Parameters.AddWithValue("@Rate", objIOWLbr.Rate);
                                                    //        Command.Parameters.AddWithValue("@Amount", objIOWLbr.Amount);
                                                    //        Command.Parameters.AddWithValue("@AppRate", objIOWLbr.AppRate);
                                                    //        Command.Parameters.AddWithValue("@MinRate", objIOWLbr.MinRate);
                                                    //        Command.Parameters.AddWithValue("@AnalysisId", 0);

                                                    //        Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                    //    }
                                                    //}

                                                    //Insert BillIOWMeasurement List<BillIOWMeasurementBOUpdate> argBIOWMsrment
                                                    int rsrceId = 0;
                                                    if (objBTrns.ResourceId == 0) { rsrceId = objBTrns.IOW_ID; }
                                                    else if (objBTrns.IOW_ID == 0) { rsrceId = objBTrns.ResourceId; }

                                                    if (objIOW.MType == 0 || objIOW.MType == 2)
                                                    {
                                                        List<BillIOWMeasurementBOUpdate> oSIOWMsrMnt = argBIOWMsrment.FindAll(delegate(BillIOWMeasurementBOUpdate del)
                                                        {
                                                            return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.AnalysisId == objIOW.AnalysisHeadID) && (del.IOWId == objIOW.IOW_ID));
                                                        });

                                                        if (oSIOWMsrMnt.Count > 0)
                                                        {
                                                            foreach (BillIOWMeasurementBOUpdate objIOWMsr in oSIOWMsrMnt)
                                                            {
                                                                Command = new SqlCommand("Insert_BillMeasurement", conn, tran);
                                                                Command.CommandType = CommandType.StoredProcedure;
                                                                Command.Parameters.Clear();
                                                                Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                                Command.Parameters.AddWithValue("@BillIOWTransId", iBillIOWTransId);
                                                                Command.Parameters.AddWithValue("@IOWId", objIOWMsr.IOWId);
                                                                Command.Parameters.AddWithValue("@RowId", objIOWMsr.BEntryRowId);
                                                                Command.Parameters.AddWithValue("@SlNo", objIOWMsr.SlNo);
                                                                Command.Parameters.AddWithValue("@Description", objIOWMsr.Description);
                                                                Command.Parameters.AddWithValue("@No1", objIOWMsr.No1);
                                                                Command.Parameters.AddWithValue("@No2", objIOWMsr.No2);
                                                                Command.Parameters.AddWithValue("@Length", objIOWMsr.Length);
                                                                Command.Parameters.AddWithValue("@Breadth", objIOWMsr.Breadth);
                                                                Command.Parameters.AddWithValue("@Depth", objIOWMsr.Depth);
                                                                Command.Parameters.AddWithValue("@Qty", objIOWMsr.Qty);
                                                                Command.Parameters.AddWithValue("@Sign", objIOWMsr.Sign);
                                                                Command.Parameters.AddWithValue("@MBookNO", objIOWMsr.MBookNO);
                                                                Command.Parameters.AddWithValue("@PageNo", objIOWMsr.PageNo);
                                                                Command.Parameters.AddWithValue("@LevelNo", objIOWMsr.LevelNo);
                                                                Command.Parameters.AddWithValue("@ParentID", objIOWMsr.ParentID);
                                                                Command.Parameters.AddWithValue("@SteelId", objIOWMsr.SteelId);
                                                                Command.Parameters.AddWithValue("@Factor", objIOWMsr.Factor);

                                                                if (CommFun.IsNullCheck(objIOWMsr.FNo1, CommFun.datatypes.vartypestring) != null)
                                                                    Command.Parameters.AddWithValue("@FNo1", CommFun.IsNullCheck(objIOWMsr.FNo1, CommFun.datatypes.vartypestring));
                                                                else
                                                                    Command.Parameters.AddWithValue("@FNo1", "");

                                                                if (CommFun.IsNullCheck(objIOWMsr.FNo2, CommFun.datatypes.vartypestring) != null)
                                                                    Command.Parameters.AddWithValue("@FNo2", CommFun.IsNullCheck(objIOWMsr.FNo2, CommFun.datatypes.vartypestring));
                                                                else
                                                                    Command.Parameters.AddWithValue("@FNo2", "");

                                                                if (Convert.ToDecimal(CommFun.IsNullCheck(objIOWMsr.FLength, CommFun.datatypes.vartypenumeric)) != 0)
                                                                    Command.Parameters.AddWithValue("@FLength", CommFun.IsNullCheck(objIOWMsr.FLength, CommFun.datatypes.vartypestring));
                                                                else
                                                                    Command.Parameters.AddWithValue("@FLength", 0);

                                                                if (Convert.ToDecimal(CommFun.IsNullCheck(objIOWMsr.FBreadth, CommFun.datatypes.vartypenumeric)) != 0)
                                                                    Command.Parameters.AddWithValue("@FBreadth", CommFun.IsNullCheck(objIOWMsr.FBreadth, CommFun.datatypes.vartypestring));
                                                                else
                                                                    Command.Parameters.AddWithValue("@FBreadth", 0);

                                                                if (Convert.ToDecimal(CommFun.IsNullCheck(objIOWMsr.FDepth, CommFun.datatypes.vartypenumeric)) != 0)
                                                                    Command.Parameters.AddWithValue("@FDepth", CommFun.IsNullCheck(objIOWMsr.FDepth, CommFun.datatypes.vartypestring));
                                                                else
                                                                    Command.Parameters.AddWithValue("@FDepth", 0);

                                                                Command.Parameters.AddWithValue("@BillType", CommFun.IsNullCheck(objBTrns.Type.ToString(), CommFun.datatypes.vartypestring));

                                                                if (CommFun.IsNullCheck(objIOWMsr.SubFormula, CommFun.datatypes.vartypestring) != null)
                                                                    Command.Parameters.AddWithValue("@SubFormula", CommFun.IsNullCheck(objIOWMsr.SubFormula, CommFun.datatypes.vartypestring));
                                                                else
                                                                    Command.Parameters.AddWithValue("@SubFormula", "");

                                                                //Command.Parameters.AddWithValue("@FNo1", objIOWMsr.FNo1);
                                                                //Command.Parameters.AddWithValue("@FNo2", objIOWMsr.FNo2);
                                                                //Command.Parameters.AddWithValue("@FLength", objIOWMsr.FLength);
                                                                //Command.Parameters.AddWithValue("@FBreadth", objIOWMsr.FBreadth);
                                                                //Command.Parameters.AddWithValue("@FDepth", objIOWMsr.FDepth);
                                                                //Command.Parameters.AddWithValue("@BillType", objIOWMsr.BillType);
                                                                //Command.Parameters.AddWithValue("@SubFormula", objIOWMsr.SubFormula);

                                                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                            }
                                                        }
                                                    }
                                                    else if (objIOW.MType == 1)
                                                    {
                                                        List<BillMSteelSelection> ocheckUpdate = oSteelSel.FindAll(
                                                            delegate(BillMSteelSelection del)
                                                            {

                                                                return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.AnalId == objIOW.AnalysisHeadID) && (del.IOWId == objIOW.IOW_ID));
                                                                //if (objIOW.AnalysisHeadID != 0)
                                                                //    return sel.BillResId == rsrceId && sel.IOWId == objIOW.IOW_ID && sel.AnalId == objIOW.AnalysisHeadID && sel.TransRowId == objBTrns.RowId;
                                                                //else
                                                                //    return sel.BillResId == rsrceId && sel.IOWId == objIOW.IOW_ID && sel.TransRowId == objBTrns.RowId;
                                                            });
                                                        if (ocheckUpdate.Count > 0)
                                                        {
                                                            foreach (BillMSteelSelection IMsrSel in ocheckUpdate)
                                                            {
                                                                sSql = "Insert INTO BillMSteelSelection(BillTransId,IOW_ID,IOW_Trans_Id,AnalId,SteelId) " +
                                                                 " Values(" + iBillTransId + "," + rsrceId + "," + objIOW.IOW_ID + "," + objIOW.AnalysisHeadID + " , " +
                                                                 " " + CommFun.IsNullCheck(IMsrSel.SteelId, CommFun.datatypes.vartypenumeric) + ")";
                                                                Command = new SqlCommand(sSql, conn, tran);
                                                                Command.ExecuteNonQuery(); Command.Dispose();
                                                                Command.Dispose();
                                                            }
                                                        }

                                                        List<BillIOWMeasurementBOUpdate> oSIOWMsrMnt = argBIOWMsrment.FindAll(
                                                            delegate(BillIOWMeasurementBOUpdate del)
                                                            {
                                                                if (objBTrns.Type == "A")
                                                                    return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.RateType == objIOW.RateType) && (del.AnalysisId == objIOW.AnalysisHeadID) && (del.IOWId == objIOW.IOW_ID));
                                                                else
                                                                    return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objBTrns.RowId) && (del.AnalysisId == objIOW.AnalysisHeadID) && (del.IOWId == objIOW.IOW_ID));
                                                            });

                                                        if (oSIOWMsrMnt.Count > 0)
                                                        {
                                                            foreach (BillIOWMeasurementBOUpdate objIOWMsr in oSIOWMsrMnt)
                                                            {
                                                                Command = new SqlCommand("Insert_BillMeasurement", conn, tran);
                                                                Command.CommandType = CommandType.StoredProcedure;
                                                                Command.Parameters.Clear();
                                                                Command.Parameters.AddWithValue("@BillTransId", iBillTransId);
                                                                Command.Parameters.AddWithValue("@BillIOWTransId", iBillIOWTransId);
                                                                Command.Parameters.AddWithValue("@IOWId", objIOWMsr.IOWId);
                                                                Command.Parameters.AddWithValue("@RowId", objIOWMsr.BEntryRowId);
                                                                Command.Parameters.AddWithValue("@SlNo", objIOWMsr.SlNo);
                                                                Command.Parameters.AddWithValue("@Description", objIOWMsr.Description);
                                                                Command.Parameters.AddWithValue("@No1", objIOWMsr.No1);
                                                                Command.Parameters.AddWithValue("@No2", objIOWMsr.No2);
                                                                Command.Parameters.AddWithValue("@Length", objIOWMsr.Length);
                                                                Command.Parameters.AddWithValue("@Breadth", 0);
                                                                Command.Parameters.AddWithValue("@Depth", objIOWMsr.Diameter);
                                                                Command.Parameters.AddWithValue("@Qty", objIOWMsr.Qty);
                                                                Command.Parameters.AddWithValue("@Sign", "");
                                                                Command.Parameters.AddWithValue("@MBookNO", 0);
                                                                Command.Parameters.AddWithValue("@PageNo", 0);
                                                                Command.Parameters.AddWithValue("@LevelNo", 0);
                                                                Command.Parameters.AddWithValue("@ParentID", 0);
                                                                Command.Parameters.AddWithValue("@SteelId", objIOWMsr.SteelId);
                                                                Command.Parameters.AddWithValue("@Factor", objIOWMsr.Factor);
                                                                Command.Parameters.AddWithValue("@FNo1", "");
                                                                Command.Parameters.AddWithValue("@FNo2", "");
                                                                Command.Parameters.AddWithValue("@FLength", "");
                                                                Command.Parameters.AddWithValue("@FBreadth", "");
                                                                Command.Parameters.AddWithValue("@FDepth", "");
                                                                Command.Parameters.AddWithValue("@BillType", objIOWMsr.BillType);
                                                                Command.Parameters.AddWithValue("@SubFormula", "");

                                                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                //Insert BillItemAbstractLabour Trans  List<BillItemLbrStrnthTransBO> argBLbrItem

                                //if (objBTrns.ResourceId == 0) { rsrceId2 = objBTrns.IOW_ID; }
                                //else if (objBTrns.IOW_ID == 0) { rsrceId2 = objBTrns.ResourceId; }
                                //List<BillItemLbrStrnthTransBO> oSItmLbrTrns2 = argBLbrItem.FindAll(delegate(BillItemLbrStrnthTransBO del) { return del.BAbsTypeId == objBTrns.BAbsTypeId && del.ItemTransId == rsrceId2; });
                                //if (oSItmLbrTrns.Count>0)
                                //{
                                //    foreach (BillItemLbrStrnthTransBO objItem in oSItmLbrTrns2)
                                //    {
                                //        Command = new SqlCommand("Insert_BillItemLabourTrans", conn, tran);
                                //        Command.CommandType = CommandType.StoredProcedure;
                                //        Command.Parameters.Clear();
                                //        Command.Parameters.AddWithValue("@BillTransID", iBillTransId);
                                //        Command.Parameters.AddWithValue("@LabourTypeID", objItem.LbrTypeId);
                                //        Command.Parameters.AddWithValue("@Qty", objItem.Qtty);
                                //        Command.Parameters.AddWithValue("@Rate", objItem.Rate);
                                //        Command.Parameters.AddWithValue("@Amount", objItem.Amount);
                                //        Command.Parameters.AddWithValue("@AppRate", objItem.AppRate);
                                //        Command.Parameters.AddWithValue("@MinRate", objItem.MinRate);

                                //        Command.ExecuteNonQuery(); Command.Dispose();
                                //    }
                                //}

                            }

                        }
                    }
                    else if (objAbs.FormatTypeId == 5)
                    {
                        //Insert TDSDetails
                        //List<BillFormateTDSBO> argBFTDS
                        List<BillFormateTDSNewBO> oSL = argBFTDS.FindAll(delegate(BillFormateTDSNewBO del) { return ((del.BAbsTypeId == objAbs.TypeId)&&(del.BAbsRowId==objAbs.RowId)); });
                        if(oSL.Count>0)
                        {
                            int sLId = CommFun.GetSubLedgerId(objAbs.QualMId, 8, conn, tran);

                            foreach (BillFormateTDSNewBO objTDSF in oSL)
                            {
                                Command = new SqlCommand("Insert_TDSBillFormatTrans", conn, tran);
                                Command.CommandType = CommandType.StoredProcedure;
                                Command.Parameters.Clear();
                                Command.Parameters.AddWithValue("@BillRegisterId", iBillRegId);
                                Command.Parameters.AddWithValue("@Formula", objTDSF.Formula);
                                Command.Parameters.AddWithValue("@TypeId", objTDSF.BAbsTypeId);
                                Command.Parameters.AddWithValue("@GrossAmt", objTDSF.GrossAmt);
                                Command.Parameters.AddWithValue("@TDSPer", objTDSF.TDSPer);
                                Command.Parameters.AddWithValue("@TDSAmt", objTDSF.TDSAmt);
                                Command.Parameters.AddWithValue("@SurPer", objTDSF.SurPer);
                                Command.Parameters.AddWithValue("@SurAmt", objTDSF.SurAmt);
                                Command.Parameters.AddWithValue("@EDPer", objTDSF.EDPer);
                                Command.Parameters.AddWithValue("@EDAmt", objTDSF.EDAmt);

                                Command.Parameters.AddWithValue("@HEDPer", objTDSF.HEDPer);
                                Command.Parameters.AddWithValue("@HEDAmt", objTDSF.HEDAmt);
                                Command.Parameters.AddWithValue("@NetPer", objTDSF.NetPer);

                                Command.Parameters.AddWithValue("@TDSNetAmt", objTDSF.NetTDSAmt);
                                Command.Parameters.AddWithValue("@QualMId", objAbs.QualMId);
                                Command.Parameters.AddWithValue("@AccountId", objAbs.AccountId);
                                Command.Parameters.AddWithValue("@SubLedgerId", sLId);

                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                            }
                        }
                    }
                    else if (objAbs.FormatTypeId == 6 && objAbs.AddType==1)
                    {
                        //Insert ServiceTaxDetails
                        //List<BillServiceTaxNewBO> argBFST
                        List<BillServiceTaxNewBO> oSL = argBFST.FindAll(delegate(BillServiceTaxNewBO del) { return ((del.BAbsTypeId == objAbs.TypeId) && (del.BAbsRowId == objAbs.RowId)); });
                        if (oSL.Count > 0)
                        {
                            int sLId = CommFun.GetSubLedgerId(objAbs.QualMId, 8, conn, tran);

                            foreach (BillServiceTaxNewBO objServiceT in oSL)
                            {
                                sSql = "Insert Into BillServiceTaxTrans(BillRegId,TypeId,Formula,GrossAmt,AccountId,TaxablePer,TaxableValue,ExpPer " +
                                ",ExpValue,SurCharge,SurValue,EDCess,EDValue,HEDCess,HEDValue,NetPer,NetAmt) " +
                                "Values (" + iBillRegId + "," + objServiceT.BAbsTypeId + ",'" + objServiceT.Formula + "'," + objServiceT.GrossAmt + "," + objServiceT.AccountId + ", " +
                                " " + objServiceT.TaxablePer + "," + objServiceT.TaxableAmt + "," + objServiceT.ExpPer + ", " +
                                " " + objServiceT.ExpPerAmt + "," + objServiceT.SurPer + "," + objServiceT.SurAmt + "," + objServiceT.EDPer + "," + objServiceT.EDAmt + " ," +
                                " " + objServiceT.HEDPer + "," + objServiceT.HEDAmt + "," + objServiceT.NetPer + "," + objServiceT.NetAmt + ")";
                                Command = new SqlCommand(sSql, conn, tran);
                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                            }
                        }
                    }

                    else if (objAbs.FormatTypeId == 3)
                    {
                        //Insert Material Recovery
                        List<BillMaterialRecovery> oSM = argBMatRec.FindAll(delegate(BillMaterialRecovery del) { return ((del.BAbsRowId == objAbs.RowId)&&(del.BAbsTypeId==objAbs.TypeId)) ; });
                        if (oSM.Count > 0)
                        {
                            foreach (BillMaterialRecovery objMat in oSM)
                            {
                                Command = new SqlCommand("Insert_BillMaterialRecovery", conn, tran);
                                Command.CommandType = CommandType.StoredProcedure;
                                Command.Parameters.Clear();
                                Command.Parameters.AddWithValue("@BillRegId", iBillRegId);
                                Command.Parameters.AddWithValue("@Comp_ID", objMat.Comp_Id);
                                Command.Parameters.AddWithValue("@Unit", objMat.Unit);
                                Command.Parameters.AddWithValue("@Qty", objMat.Qty);
                                Command.Parameters.AddWithValue("@Rate", objMat.Rate);
                                Command.Parameters.AddWithValue("@Amount", objMat.Amount);
                                Command.Parameters.AddWithValue("@IssueId", objMat.IssueId);
                                Command.Parameters.AddWithValue("@TypeId", objMat.BAbsTypeId);

                                Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                            }
                            if (BsfGlobal.g_bMMSDB == true)
                            {
                                sSql = "Update [" + BsfGlobal.g_sMMSDBName + "].dbo.IssueTrans Set RecQty=RecQty+Qty " +
                                         "from BillMaterialRecovery WHERE " +
                                         "BillRegId = " + iBillRegId + " And IssueId <> 0 " +
                                         "and [" + BsfGlobal.g_sMMSDBName + "].dbo.IssueTrans.IssueTransId=BillMaterialRecovery.IssueId ";

                                Command = new SqlCommand(sSql, conn, tran);
                                Command.ExecuteNonQuery(); Command.Dispose();
                                Command.Dispose();
                            }
                        }
                    }
                    else if (objAbs.FormatTypeId == 9)
                    {
                        if ((objAbs.BFormatType == "B" || objAbs.BFormatType == "A") && argInternal == true && (objAbs.AddType == 1 || objAbs.AddType == 0))
                        {

                            if (objAbs.BFormatType == "B" && argInternal == true && objAbs.AddType == 0)
                            {
                                if (dtLbrAdj.Rows.Count > 0)
                                {
                                    foreach (DataRow dr in dtLbrAdj.Rows)
                                    {
                                        decimal AdvAmount = Convert.ToDecimal(CommFun.IsNullCheck(dr["CAmount"], CommFun.datatypes.vartypenumeric));
                                        if (AdvAmount > 0)
                                        {
                                            sSql = "Insert Into LabourAdvAdjustment (BillRegisterId,LabourId,Amount,RegId,TypeId)  " +
                                                "Values (" + iBillRegId + "," + dr["LabourId"] + ",'" + AdvAmount + "'," + dr["RegId"] + "," + objAbs.TypeId+ ") ";
                                            Command = new SqlCommand(sSql, conn, tran);
                                            Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                        }
                                    }
                                }
                            }
                            if (objAbs.BFormatType == "A" && argInternal == true && objAbs.AddType == 1)
                            {
                                int iSign = 0;
                                List<BillLabourAdvance> chkAdv = argBLbrAdv.FindAll(
                                    delegate(BillLabourAdvance del)
                                    {
                                        return ((del.bAbsRowId == objAbs.RowId) && (del.bAbsTypeId == objAbs.TypeId));
                                    });
                                if (chkAdv.Count > 0)
                                {
                                    foreach (BillLabourAdvance objLAdv in chkAdv)
                                    {
                                        if (objLAdv.Sign == "+")
                                            iSign = 1;
                                        else
                                            iSign = 0;

                                        sSql = "Insert Into BillLabourAdvance(BillRegisterId,BFormatType,LabourId,TypeId,Sign,Amount)  values " +
                                            "(" + iBillRegId + ",'" + objAbs.BFormatType + "'," + objLAdv.LabourId + "," + objLAdv.bAbsTypeId + "," + iSign + "," + objLAdv.Amount + ")";
                                        Command = new SqlCommand(sSql, conn, tran);
                                        Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();

                                    }
                                }
                            }
                        }
                    }
                    else if (objAbs.FormatTypeId == 4)
                    {

                        if (argInternal == false && objAbs.BFormatType.ToString() == "B")
                        {
                            List<BillLabourTypeTransBO> oSLt = argBLbrType.FindAll(delegate(BillLabourTypeTransBO del) { return (del.TypeId == objAbs.TypeId); });
                            if (oSLt.Count > 0)
                            {
                                foreach (BillLabourTypeTransBO objLType in oSLt)
                                {
                                    if (objLType.Qty != 0)
                                    {
                                        int iFromLS = 0;
                                        if (objLType.FromLS == true) { iFromLS = 1; }

                                        sSql = "Insert into BillLabourTypeTrans(BillRegisterId,LabourTypeId,TypeId,qty,Rate,Amount,FromLS) " +
                                               "Values(" + iBillRegId + "," + objLType.LabourTypeID + "," + objLType.TypeId + "," + objLType.Qty + "," + objLType.Rate + "," + objLType.Amount + "," + iFromLS + ") SELECT SCOPE_IDENTITY();";
                                        Command = new SqlCommand(sSql, conn, tran);
                                        int iTransId = int.Parse(Command.ExecuteScalar().ToString());
                                        Command.Dispose();

                                        if (argLSWBS.Count > 0)
                                        {
                                            List<BillLSWBSTrans> oSLt2 = argLSWBS.FindAll(delegate(BillLSWBSTrans del) { return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objLType.RowId)); });

                                            if (oSLt2.Count > 0)
                                            {
                                                foreach (BillLSWBSTrans objLSWBS in oSLt2)
                                                {
                                                    if (objLSWBS.Qty != 0)
                                                    {
                                                        sSql = "Insert Into BillLabourTypeWBSTrans (BillLabourTypeTransId,AnalysisId,Qty) " +
                                                               "Values (" + iTransId + "," + objLSWBS.AnalysisId + "," + objLSWBS.Qty + ") SELECT SCOPE_IDENTITY();";
                                                        Command = new SqlCommand(sSql, conn, tran);
                                                        int iWBSTransId = int.Parse(Command.ExecuteScalar().ToString());
                                                        Command.Dispose();

                                                        List<BillLSVTrans> oLSV = argBillLSV.FindAll(delegate(BillLSVTrans del) { return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objLType.RowId) && (del.AnalysisId == objLSWBS.AnalysisId)); });

                                                        if (oLSV.Count > 0)
                                                        {
                                                            foreach (BillLSVTrans objLSV in oLSV)
                                                            {
                                                                sSql = "Insert into BillLabourTypeWBSLSTrans(BillLSWBSTransId,LSId,Qty) " +
                                                                       "Values(" + iWBSTransId + "," + objLSV.LSId + ", " + objLSV.BillQty + ")";
                                                                Command = new SqlCommand(sSql, conn, tran);
                                                                Command.ExecuteNonQuery();
                                                                Command.Dispose();
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (argBillLSV.Count >0)
                                            {
                                                List<BillLSVTrans> oLSV = argBillLSV.FindAll(delegate(BillLSVTrans del) { return ((del.TypeId == objAbs.TypeId) && (del.TransRowId == objLType.RowId)); });

                                                if (oLSV.Count > 0)
                                                {
                                                    foreach (BillLSVTrans objLSV in oLSV)
                                                    {
                                                        sSql = "Insert into BillLabourTypeWBSLSTrans(BillLabourTypeTransId,LSId,Qty) " +
                                                               "Values(" + iTransId + "," + objLSV.LSId + ", " + objLSV.BillQty + ")";
                                                        Command = new SqlCommand(sSql, conn, tran);
                                                        Command.ExecuteNonQuery();
                                                        Command.Dispose();
                                                    }
                                                }
                                            }
                                        }
                                    }

                                }
                            }
                        }
                        else if (argInternal == true && objAbs.BFormatType.ToString() == "B")
                        {
                            List<BillLabourTypeTransBO> oSLt = argBLbrType.FindAll(delegate(BillLabourTypeTransBO del) { return ((del.TypeId == objAbs.TypeId)); });
                            if (oSLt.Count > 0)
                            {
                                foreach (BillLabourTypeTransBO objLType in oSLt)
                                {
                                    if (objLType.Qty != 0)
                                    {
                                        sSql = "Insert BillMLabourTrans(BillRegisterId,LabourId,TypeId,Qty,Rate,Amount) " +
                                               "Values(" + iBillRegId + "," + objLType.LabourTypeID + "," + objLType.TypeId + "," + objLType.Qty + "," + objLType.Rate + "," + objLType.Amount + ")";
                                        Command = new SqlCommand(sSql, conn, tran);
                                        Command.ExecuteNonQuery(); Command.Dispose(); Command.Dispose();
                                    }

                                }
                            }
                        }

                    }
                }
                #endregion

                //if (argBReg.BillType == "I")
                //{
                //    sSql = "Insert into BillItemLabourTrans(BillTransId,LabourTypeId,Qty,Rate,Amount) " +
                //           "Select BillTransId,LabourTypeId,Sum(Qty) Qty,Case When Sum(isnull(Qty,0)) <>0 then  Sum(Amount)/Sum(Qty) else 0 end Rate,Sum(Amount) Amount from BillWBSLabourTrans " +
                //           "Where BillTransId in (Select BillTransId from BillTrans Where BillRegisterId = " + iBillRegId + ") Group by BillTransId,LabourTypeId";
                //    Command = new SqlCommand(sSql, conn, tran); Command.ExecuteNonQuery(); Command.Dispose();
                //}
                //else
                //{
                //    sSql = "Insert into BillItemLabourTrans(BillTransId,LabourTypeId,Qty,Rate,Amount) " +
                //           "Select BillTransId,LabourTypeId,Sum(Qty) Qty,Case When Sum(isnull(Qty,0)) <>0 then  Sum(Amount)/Sum(Qty) else 0 end Rate,Sum(Amount) Amount from BillIOWLabourTrans " +
                //           "Where BillTransId in (Select BillTransId from BillTrans Where BillRegisterId = " + iBillRegId + ") Group by BillTransId,LabourTypeId";
                //    Command = new SqlCommand(sSql, conn, tran); Command.ExecuteNonQuery(); Command.Dispose();
                //}

                //sSql = "Insert into BillLabourTrans(BillREgisterId,LabourTypeId,Qty,Rate,Amount) " +
                //       "Select " + iBillRegId + ",LabourTypeId,Sum(Qty) Qty,Case When Sum(isnull(Qty,0)) <>0 then  Sum(Amount)/Sum(Qty) else 0 end Rate,Sum(Amount) Amount from BillItemLabourTrans " +
                //       "Where BillTransId in (Select BillTransId from BillTrans Where BillRegisterId = " + iBillRegId + ") Group by LabourTypeId";
                //Command = new SqlCommand(sSql, conn, tran); Command.ExecuteNonQuery(); Command.Dispose();

                CommFun.ActualCompUpdate(iBillRegId, argCCId, "B", true, argRevId, argBReg.ContractorID, argDBName, conn, tran, argBReg.CostOption);

                //BsfGlobal.UpdateMaxNo(13, oVType, 0, 0, conn, tran);
                //BsfGlobal.UpdateMaxNo(13, oVCCType, 0, argBReg.CostCentreId, conn, tran);
                //BsfGlobal.UpdateMaxNo(13, oVCompanyType, argBReg.CompanyId, 0, conn, tran);

                //BillQty Update in WOTrans Table
                if (argBReg.WORegisterID!=0)
                    CommFun.RefreshWOBilledQty(argBReg.WORegisterID, conn, tran);

                sSql = "SELECT A.TypeId,A.Amount,B.Type from BillFormatTrans A  " +
                        "INNER JOIN BillFormatMaster B ON A.TypeId=B.TypeId " +
                        "WHERE A.BillRegisterId=" + iBillRegId + " and A.AccountId <>0 and A.Amount <>0 AND B.Header=0";
                Command = new SqlCommand(sSql, conn, tran);
                SqlDataReader dsr = Command.ExecuteReader();
                DataTable dt = new DataTable();
                dt.Load(dsr);
                Command.Dispose();
                dsr.Close();

                DataTable dtt;
                decimal dFAmt = 0;
                decimal dIOWAmt = 0;
                bool bAmtOK = true;
                int iTypeId = 0;

                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    dFAmt =Math.Round(Convert.ToDecimal(CommFun.IsNullCheck(dt.Rows[j]["Amount"], CommFun.datatypes.vartypenumeric)),0);
                    iTypeId = Convert.ToInt32(CommFun.IsNullCheck(dt.Rows[j]["TypeId"], CommFun.datatypes.vartypenumeric));
                    dIOWAmt = 0;

                    // Refer T-Tracker Point No 1786, Function to post subledger details-Workgroup wise posting to FA
                    if (dt.Rows[j]["Type"].ToString() == "I")
                    {
                        if (argBReg.BillType == "I")
                        {
                            sSql = "Select Sum(A.Amount) Amt From BillTrans A " +
                                    "Where A.BillRegisterId=" + iBillRegId + " and A.TypeId = " + iTypeId;
                        }
                        else
                        {
                            sSql = "Select Sum(A.Qty*B.Rate) Amt From BillIOWTrans A " +
                                    "Inner Join BillTrans B on A.BillTransId=B.BillTransId " +
                                    "Where B.BillRegisterId=" + iBillRegId + " and B.TypeId = " + iTypeId;
                        }

                        Command = new SqlCommand(sSql, conn, tran);
                        dsr = Command.ExecuteReader();
                        dtt = new DataTable();
                        dtt.Load(dsr);
                        Command.Dispose();
                        dsr.Close();

                        if (dtt.Rows.Count > 0) { dIOWAmt = Math.Round(Convert.ToDecimal(CommFun.IsNullCheck(dtt.Rows[0]["Amt"], CommFun.datatypes.vartypenumeric)), 0); }
                        dtt.Dispose();

                        if (dIOWAmt != 0)
                        {
                            if (dFAmt != dIOWAmt)
                            {
                                bAmtOK = false;
                                break;
                            }
                        }
                     }
                 }

                if (bAmtOK == false)
                {
                    tran.Rollback();
                    MessageBox.Show("Amount Difference, Do Not Update");
                    argUpdate = false;
                }
                else
                {
                    tran.Commit();
                    if (sCVType == "CC") argRefNo = argBReg.CCBVNo; else if (sCVType == "CO") argRefNo = argBReg.CompanyBVNo; else argRefNo = argBReg.VNo;
                    argUpdate = true;
                }
                //argRefNo = argBReg.BillNo;

            }
            catch (SqlException ex)
            {
               tran.Rollback();
               argUpdate = false;
               BsfGlobal.CustomException(ex.Message, ex.StackTrace);
            }
            finally
            {
                conn.Close();
            }
            return iBillRegId;
        }
Пример #12
0
        private void UpdateData()
        {
            dtpDPEDate.DoValidate();
            dtpFrmDate.DoValidate();
            dtpToDate.DoValidate();

            if (gridView1.RowCount == 0)
            {
                MessageBox.Show("There is No Item", "WPM", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (BsfGlobal.FindPermission("General-Allow-Future-Date-Entries") == false)
            {
                BsfGlobal.Get_ServerDate();
                if (Convert.ToDateTime(Convert.ToDateTime(dtpDPEDate.EditValue).ToString("dd MMM yyyy")) > BsfGlobal.g_dServerDate)
                {
                    MessageBox.Show("DQE Date is Greater than Current Date. Cannot Proceed...");
                    dtpDPEDate.Focus();
                    return;
                }
            }

            if (BsfGlobal.FindPermission("General-Allow-Back-Date-Entries") == false)
            {
                Nullable<DateTime> dNulldate = BsfGlobal.GetFreezeBackDate(96);
                if (dNulldate != null)
                {
                    if (Convert.ToDateTime(Convert.ToDateTime(dtpDPEDate.EditValue).ToString("dd MMM yyyy")) < dNulldate)
                    {
                        string stg = "Do Not Allow Back Date Entry Before" + dNulldate.ToString();
                        MessageBox.Show(stg, "WPM", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }

            oDQEReg = new DQEMasterBO();
            oDQEReg.EDate = Convert.ToDateTime(dtpDPEDate.EditValue);
            oDQEReg.FDate = Convert.ToDateTime(dtpFrmDate.EditValue);
            oDQEReg.TDate = Convert.ToDateTime(dtpToDate.EditValue);
            oDQEReg.CCVNo = txtCCDPENo.Text;
            oDQEReg.CompVNo = txtCompBVNo.Text;
            oDQEReg.VNo = txtLVNo.Text;
            oDQEReg.CostCentreId = m_iCCId;
            oDQEReg.UserId = Convert.ToInt32(CommFun.IsNullCheck(cboUser.EditValue,CommFun.datatypes.vartypenumeric));
            oDQEReg.Narration = CommFun.Insert_SingleQuot(CommFun.IsNullCheck(txtNote.EditValue, CommFun.datatypes.vartypestring).ToString());
            oDQEReg.Ready = Convert.ToBoolean(barEditItem1.EditValue);

            bool bUpdate = false;
            string sRefNo = "";
            if (m_sMode == "A")
            {
                int iRegId = 0;
                bUpdate = oDQE.InsertDQE(oDQEReg, m_tIOWTrans, oDQEWBSTrans, ref iRegId, ref sRefNo);

                if (bUpdate == true)
                {
                    if (Convert.ToBoolean(barEditItem1.EditValue) == true)
                    {
                        BsfGlobal.Get_ServerDate();
                        BsfGlobal.InsertLog(BsfGlobal.g_dServerDateTime, "DQE-Entry-Create", "N", "DQE-Entry", iRegId, m_iCCId, m_iCompanyId, BsfGlobal.g_sWPMDBName, sRefNo, BsfGlobal.g_lUserId);
                    }
                    ClearEntries();
                    cboCostcentre.Focus();
                }
            }
            else
            {
                if (m_dEntryDate != Convert.ToDateTime(dtpDPEDate.EditValue))
                {
                    if (oVType.PeriodWise == true)
                    {

                        if (BsfGlobal.CheckPeriodChange(oDQEReg.EDate, Convert.ToDateTime(dtpDPEDate.EditValue)) == true)
                        {
                            oVType = BsfGlobal.GetVoucherNo(96, Convert.ToDateTime(dtpDPEDate.EditValue), 0, 0);
                            if (oVCCType.GenType == true)
                            {
                                txtLVNo.Text = oVType.VoucherNo;
                                oDQEReg.VNo = oVType.VoucherNo;
                            }
                            oVCCType = BsfGlobal.GetVoucherNo(96, Convert.ToDateTime(dtpDPEDate.EditValue), 0, oDQEReg.CostCentreId);
                            if (oVCCType.GenType == true)
                            {
                                txtCCDPENo.Text = oVCCType.VoucherNo;
                                oDQEReg.CCVNo = oVCCType.VoucherNo;
                            }

                            oVCompanyType = BsfGlobal.GetVoucherNo(96, Convert.ToDateTime(dtpDPEDate.EditValue), oDQEReg.CompanyId, 0);
                            if (oVCompanyType.GenType == true)
                            {
                                txtCompBVNo.Text = oVCompanyType.VoucherNo;
                                oDQEReg.CompVNo = oVCompanyType.VoucherNo;
                            }

                            BsfGlobal.UpdateMaxNo(96, oVType, 0, 0);
                            BsfGlobal.UpdateMaxNo(96, oVCCType, 0, oDQEReg.CostCentreId);
                            BsfGlobal.UpdateMaxNo(96, oVCompanyType, oDQEReg.CompanyId, 0);
                        }
                    }
                }

                bUpdate = oDQE.UpdateDQE(m_iRegId, oDQEReg, m_tIOWTrans, oDQEWBSTrans);
                if (bUpdate == true)
                {
                    if (m_sVoucherType == "GE" || m_sVoucherType == "  ")
                    { sRefNo = oDQEReg.VNo; }
                    else if (m_sVoucherType == "CC")
                    { sRefNo = oDQEReg.CCVNo; }
                    else if (m_sVoucherType == "CO")
                    { sRefNo = oDQEReg.CompVNo; }

                    if (Convert.ToBoolean(barEditItem1.EditValue) == true)
                    {
                        BsfGlobal.Get_ServerDate();
                        if (barEditItem1.Enabled == true)
                        {
                            BsfGlobal.InsertLog(BsfGlobal.g_dServerDateTime, "DQE-Entry-Create", "N", "DQE-Entry", m_iRegId, m_iCCId, m_iCompanyId, BsfGlobal.g_sWPMDBName, sRefNo, BsfGlobal.g_lUserId);
                        }
                        else
                        {
                            BsfGlobal.InsertLog(BsfGlobal.g_dServerDateTime, "DQE-Entry-Modify", "E", "DQE-Entry", m_iRegId, m_iCCId, m_iCompanyId, BsfGlobal.g_sWPMDBName, sRefNo, BsfGlobal.g_lUserId);
                        }
                    }

                    this.Close();
                }
            }
        }
Пример #13
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            int iTypeId = 0;

            if (optStatusType.SelectedIndex == 0)
            {
                iTypeId = 18;
            }
            else if (optStatusType.SelectedIndex == 1)
            {
                iTypeId = 19;
            }
            else if (optStatusType.SelectedIndex == 2)
            {
                iTypeId = 20;
            }

            bool bChange = false;

            if (Validation() == true)
            {
                if (m_lRegTransId == 0)
                {
                    UpdateRegNo();
                }
                else
                {
                    if (m_dOldDate != Convert.ToDateTime(dtpDate.Text))
                    {
                        if (oVType.PeriodWise == true)
                        {
                            if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(dtpDate.Text)))
                            {
                                oVType        = new BsfGlobal.VoucherType();
                                oVType        = BsfGlobal.GetVoucherNo(iTypeId, Convert.ToDateTime(dtpDate.Text), 0, 0);
                                txtRefNo.Text = oVType.VoucherNo;
                                bChange       = true;
                            }
                        }
                    }
                }


                m_oRegister.RegTransId = m_lRegTransId;
                m_oRegister.RegisterId = Convert.ToInt32(cboReg.EditValue);
                m_oRegister.RegDate    = Convert.ToDateTime(dtpDate.EditValue);
                m_oRegister.RegNo      = txtRefNo.Text;
                m_oRegister.VendorId   = Convert.ToInt32(txtVendorName.Tag);
                if (optStatusType.SelectedIndex == 0)
                {
                    m_oRegister.StatusType = "R";
                }
                else if (optStatusType.SelectedIndex == 1)
                {
                    m_oRegister.StatusType = "S";
                }
                else if (optStatusType.SelectedIndex == 2)
                {
                    m_oRegister.StatusType = "B";
                }

                m_oRegister.Supply   = chkSupply.Checked;
                m_oRegister.SFDate   = Convert.ToDateTime(dtpSFDate.EditValue);
                m_oRegister.STDate   = Convert.ToDateTime(dtpSTDate.EditValue);
                m_oRegister.SLife    = chkSLife.Checked;
                m_oRegister.SGradeId = Convert.ToInt32(txtSGradeName.Tag);

                m_oRegister.Contract = chkContract.Checked;
                m_oRegister.CFDate   = Convert.ToDateTime(dtpCFDate.EditValue);
                m_oRegister.CTDate   = Convert.ToDateTime(dtpCTDate.EditValue);
                m_oRegister.CLife    = chkCLife.Checked;
                m_oRegister.CGradeId = Convert.ToInt32(txtCGradeName.Tag);


                m_oRegister.Service  = chkService.Checked;
                m_oRegister.HFDate   = Convert.ToDateTime(dtpHFDate.EditValue);
                m_oRegister.HTDate   = Convert.ToDateTime(dtpHTDate.EditValue);
                m_oRegister.HLife    = chkHLife.Checked;
                m_oRegister.HGradeId = Convert.ToInt32(txtHGradeName.Tag);

                m_oRegister.Remarks = txtRemarks.Text;


                if (m_lRegTransId == 0)
                {
                    m_oRegister.InsertRegTrans(m_oRegister, iTypeId);
                    BsfGlobal.UpdateMaxNo(iTypeId, oVType, 0, 0);
                    if (optStatusType.SelectedIndex == 0)
                    {
                        BsfGlobal.InsertAlert("Vendor-Renewal", "" + cboReg.Text + " - Renewed Successfully", 0, BsfGlobal.g_sVendorDBName);
                    }
                    else if (optStatusType.SelectedIndex == 1)
                    {
                        BsfGlobal.InsertAlert("Vendor-BlackList", "" + cboReg.Text + " - Blocked", 0, BsfGlobal.g_sVendorDBName);
                    }
                    else if (optStatusType.SelectedIndex == 2)
                    {
                        BsfGlobal.InsertAlert("Vendor-Suspend", "" + cboReg.Text + " - Suspended", 0, BsfGlobal.g_sVendorDBName);
                    }
                }
                else
                {
                    m_oRegister.UpdateRegTrans(m_oRegister);
                    if (bChange == true)
                    {
                        BsfGlobal.UpdateMaxNo(iTypeId, oVType, 0, 0);
                    }
                }
                m_oRegUpdate.UpdateRegistration(Convert.ToInt32(txtVendorName.Tag));
                this.Close();
            }
        }
Пример #14
0
        private void barButtonItemOk_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (txtRefNo.Text.Trim() == "")
            {
                MessageBox.Show("Provide ReferenceNo", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txtRefNo.Focus();
                return;
            }
            else if (Convert.ToInt32(cboProject.EditValue) == -1 || Convert.ToInt32(cboProject.EditValue) == 0)
            {
                MessageBox.Show("Select Project Type", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                cboProject.Focus();
                return;
            }
            else if (Convert.ToInt32(cboQuote.EditValue) == -1 || Convert.ToInt32(cboQuote.EditValue) == 0)
            {
                MessageBox.Show("Select Ref Quote Type", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                cboQuote.Focus();
                return;
            }
            else if (txtFlat.Text.Trim() == "")
            {
                MessageBox.Show("Provide Flat", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txtFlat.Focus();
                return;
            }
            else if (txtBuyer.Text.Trim() == "")
            {
                MessageBox.Show("Provide Buyer", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txtBuyer.Focus();
                return;
            }

            grdViewService.FocusedRowHandle = grdViewService.FocusedRowHandle + 1;
            if (grdViewService.RowCount <= 0)
            {
                MessageBox.Show("Blank Posting Zero", "ASSET", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return;
            }
            else
            {
                if (grdViewService.RowCount > 0)
                {
                    for (int t = 0; t < grdViewService.RowCount; t++)
                    {
                        decimal dQA = Convert.ToDecimal(CommFun.IsNullCheck(grdViewService.GetRowCellValue(t, "Amount").ToString(), CommFun.datatypes.vartypenumeric));
                        if (dQA == 0)
                        {
                            MessageBox.Show("Amount Check", "ASSET", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return;
                        }
                    }
                }
            }

            if (m_iRegBillId == 0)
            {
                if (oVType.GenType == true)
                {
                    oVType        = new BsfGlobal.VoucherType();
                    oVType        = BsfGlobal.GetVoucherNo(29, Convert.ToDateTime(dtpRefDate.EditValue), 0, 0);
                    txtRefNo.Text = oVType.VoucherNo;
                }
            }
            else
            {
                if (oVType.PeriodWise == true)
                {
                    oVType = new BsfGlobal.VoucherType();
                    if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(dtpRefDate.EditValue)) == true)
                    {
                        oVType = BsfGlobal.GetVoucherNo(29, Convert.ToDateTime(dtpRefDate.EditValue), 0, 0);
                    }
                }
            }

            if (m_iRegBillId == 0)
            {
                oSoBO = new ServiceOrderBillBO();
                ServiceOrderBillBO.RegBillId    = m_iRegBillId;
                ServiceOrderBillBO.Billdate     = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtpRefDate.EditValue, CommFun.datatypes.VarTypeDate));
                ServiceOrderBillBO.BillRefNo    = CommFun.IsNullCheck(txtRefNo.Text, CommFun.datatypes.vartypestring).ToString();
                ServiceOrderBillBO.CostcentreID = Convert.ToInt32(CommFun.IsNullCheck(cboProject.EditValue, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.FlatID       = Convert.ToInt32(CommFun.IsNullCheck(txtFlat.Tag, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.GrossAmt     = Convert.ToDecimal(CommFun.IsNullCheck(txtTotal.Text, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.QualifierAmt = Convert.ToDecimal(CommFun.IsNullCheck(txtQTotal.Text, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.NetAmt       = Convert.ToDecimal(CommFun.IsNullCheck(txtNAmt.Text, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.Narration    = CommFun.IsNullCheck(txtNarration.Text, CommFun.datatypes.vartypestring).ToString();
                ServiceOrderBillBO.QuoteRegId   = Convert.ToInt32(CommFun.IsNullCheck(cboQuote.EditValue, CommFun.datatypes.vartypenumeric));
                bSuccess = ServiceOrderBillBL.InsertSerOrderBill(m_dtComPList, QualTrans);
                //CommFun.InsertLog(DateTime.Now, "Service Order Details-Add", "N", "Service Order Details", BsfGlobal.g_lUserId, 0, m_iCCId, 0, BsfGlobal.g_sCRMDBName);
                BsfGlobal.UpdateMaxNo(29, oVType, 0, 0);
            }
            else
            {
                oSoBO = new ServiceOrderBillBO();
                ServiceOrderBillBO.RegBillId    = m_iRegBillId;
                ServiceOrderBillBO.Billdate     = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtpRefDate.EditValue, CommFun.datatypes.VarTypeDate));
                ServiceOrderBillBO.BillRefNo    = CommFun.IsNullCheck(txtRefNo.Text, CommFun.datatypes.vartypestring).ToString();
                ServiceOrderBillBO.CostcentreID = Convert.ToInt32(CommFun.IsNullCheck(cboProject.EditValue, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.FlatID       = Convert.ToInt32(CommFun.IsNullCheck(txtFlat.Tag, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.GrossAmt     = Convert.ToDecimal(CommFun.IsNullCheck(txtTotal.Text, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.QualifierAmt = Convert.ToDecimal(CommFun.IsNullCheck(txtQTotal.Text, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.NetAmt       = Convert.ToDecimal(CommFun.IsNullCheck(txtNAmt.Text, CommFun.datatypes.vartypenumeric));
                ServiceOrderBillBO.Narration    = CommFun.IsNullCheck(txtNarration.Text, CommFun.datatypes.vartypestring).ToString();
                ServiceOrderBillBO.QuoteRegId   = Convert.ToInt32(CommFun.IsNullCheck(cboQuote.EditValue, CommFun.datatypes.vartypenumeric));

                if (Convert.ToDateTime(ServiceOrderBillBO.Billdate) != Convert.ToDateTime(dtpRefDate.EditValue))
                {
                    oVType = new BsfGlobal.VoucherType();
                    if (oVType.PeriodWise == true)
                    {
                        if (BsfGlobal.CheckPeriodChange(Convert.ToDateTime(ServiceOrderBillBO.Billdate), Convert.ToDateTime(dtpRefDate.EditValue)) == true)
                        {
                            oVType        = BsfGlobal.GetVoucherNo(29, Convert.ToDateTime(dtpRefDate.EditValue), 0, 0);
                            txtRefNo.Text = oVType.VoucherNo;
                            BsfGlobal.UpdateMaxNo(29, oVType, 0, 0);
                        }
                    }
                }
                bSuccess = ServiceOrderBillBL.UpdateSerOrderBill(m_dtComPList, QualTrans);
                //CommFun.InsertLog(DateTime.Now, "Service Order Bill Details-Add", "N", "Add Service Order Bill Details", BsfGlobal.g_lUserId, 0, m_iCCId, 0, BsfGlobal.g_sCRMDBName);
            }
            if (bSuccess == true)
            {
                if (m_iRegBillId == 0)
                {
                    ClearEntries();
                }
                else
                {
                    //if (BsfGlobal.g_bWorkFlow == true)
                    //{
                    //    Close();
                    //    Cursor.Current = Cursors.WaitCursor;
                    //    frmServiceOrderBillReg frmProg = new frmServiceOrderBillReg();
                    //    frmProg.TopLevel = false;
                    //    frmProg.FormBorderStyle = FormBorderStyle.None;
                    //    frmProg.Dock = DockStyle.Fill;
                    //    frmServiceOrderBillReg.m_oDW.Show();
                    //    frmServiceOrderBillReg.t_panel.Controls.Clear();
                    //    frmServiceOrderBillReg.t_panel.Controls.Add(frmProg);
                    //    frmProg.Show();
                    //    Cursor.Current = Cursors.Default;
                    //}
                    //else
                    //{
                    //    Close();
                    //}
                    Close();
                }
            }
        }
Пример #15
0
        private void cboCostcentre_EditValueChanged(object sender, EventArgs e)
        {
            if (Convert.ToInt32(cboCostcentre.EditValue) == 0) { return; }
            if (Convert.ToInt32(cboCostcentre.EditValue) != 0)
            {
                m_iCCId = Convert.ToInt32(cboCostcentre.EditValue);
                m_sProjDBName = CommFun.GetProjectDB(m_iCCId);
                m_iRevId = 0;
                m_tWBSRights = new DataTable();

                if (BsfGlobal.CheckDBFound(m_sProjDBName) == true)
                {
                    m_iRevId = CommFun.GetRevisionId(m_sProjDBName);
                }
                else
                {
                    MessageBox.Show("Project DataBase Not Linked in this CostCentre...");
                    cboCostcentre.EditValue = 0;
                    return;
                }

                m_tWBSRights = BsfGlobal.GetWBSRights(BsfGlobal.g_lUserId, m_sProjDBName);
                DataTable dtC = new DataTable();
                dtC = CommFun.GetCompanyId(m_iCCId);
                if (dtC.Rows.Count > 0)
                {
                    m_iCompanyId = Convert.ToInt32(CommFun.IsNullCheck(dtC.Rows[0]["CompanyId"], CommFun.datatypes.vartypenumeric));
                }
                m_sSplit = CommFun.GetWBSReqd(m_iCCId);
                int iFACCId = CommFun.GetFACCId2(m_iCCId);

                oVType = new BsfGlobal.VoucherType();
                oVCCType = new BsfGlobal.VoucherType();
                oVCompanyType = new BsfGlobal.VoucherType();

                if (m_sMode == "A")
                {
                    m_sVoucherType = BsfGlobal.GetVoucherType(96);
                    oVCCType = BsfGlobal.GetVoucherNo(96, Convert.ToDateTime(dtpDPEDate.EditValue), 0, Convert.ToInt32(cboCostcentre.EditValue));
                    if (oVCCType.GenType == true)
                    {
                        if (m_sVoucherType == "CC")
                        {
                            barStaticItem1.Caption = oVCCType.VoucherNo;
                            txtCCDPENo.Text = oVCCType.VoucherNo;
                            txtCCDPENo.Enabled = false;
                            lblCCDPENo.Enabled = false;
                        }
                        else
                        {
                            txtCCDPENo.Enabled = true;
                            txtCCDPENo.Text = oVCCType.VoucherNo;
                            txtCCDPENo.Visible = true;
                            lblCCDPENo.Visible = true;
                        }
                    }
                    else
                    {
                        txtCCDPENo.Enabled = true;
                        txtCCDPENo.Text = "";
                    }
                    oVCompanyType = BsfGlobal.GetVoucherNo(96, Convert.ToDateTime(dtpDPEDate.EditValue), m_iCompanyId, 0);
                    if (oVCompanyType.GenType == true)
                    {
                        if (m_sVoucherType == "CO")
                        {
                            barStaticItem1.Caption = oVCompanyType.VoucherNo;
                            txtCompBVNo.Text = oVCompanyType.VoucherNo;
                            txtCompBVNo.Enabled = false;
                            lblCompNo.Enabled = false;
                        }
                        else
                        {
                            txtCompBVNo.Enabled = false;
                            txtCompBVNo.Text = oVCompanyType.VoucherNo;
                            txtCompBVNo.Visible = true;
                            lblCompNo.Visible = true;
                        }
                    }
                    else
                    {
                        txtCompBVNo.Enabled = true;
                        txtCompBVNo.Text = "";
                    }
                }
                if (m_sMode == "E")
                {
                    if (m_sVoucherType == "  " || m_sVoucherType == "GE")
                    {
                        lblDPENo.Enabled = false;
                        txtLVNo.Enabled = false;
                        barStaticItem1.Caption = m_tReg.Rows[0]["VNo"].ToString();
                        txtLVNo.Text = m_tReg.Rows[0]["VNo"].ToString();
                    }
                    else
                    {
                        lblDPENo.Visible = true;
                        txtLVNo.Visible = true;
                        txtLVNo.Text = m_tReg.Rows[0]["VNo"].ToString();
                        txtLVNo.Enabled = false;
                    }
                    if (m_sVoucherType == "CO")
                    {
                        lblCompNo.Enabled = false;
                        txtCompBVNo.Enabled = false;
                        txtCompBVNo.Text = m_tReg.Rows[0]["CompanyVNo"].ToString();
                        barStaticItem1.Caption = m_tReg.Rows[0]["CompanyVNo"].ToString();
                    }
                    else
                    {
                        lblCompNo.Visible = true;
                        txtCompBVNo.Visible = true;
                        txtCompBVNo.Text = m_tReg.Rows[0]["CompanyVNo"].ToString();
                        txtCompBVNo.Enabled = false;
                    }
                    if (m_sVoucherType == "CC")
                    {
                        lblCCDPENo.Enabled = false;
                        txtCCDPENo.Enabled = false;
                        txtCCDPENo.Text = m_tReg.Rows[0]["CCDQENo"].ToString();
                        barStaticItem1.Caption = m_tReg.Rows[0]["CCDQENo"].ToString();
                    }
                    else
                    {
                        lblCCDPENo.Visible = true;
                        txtCCDPENo.Visible = true;
                        txtCCDPENo.Text = m_tReg.Rows[0]["CCDQENo"].ToString();
                        txtCCDPENo.Enabled = false;
                    }

                }
            }
        }
Пример #16
0
        private void GetVoucherNo()
        {
            m_sVoucherType = BsfGlobal.GetVoucherType(96);

            oVType = new BsfGlobal.VoucherType();
            oVType = BsfGlobal.GetVoucherNo(96, Convert.ToDateTime(dtpDPEDate.EditValue), 0, 0);

            BsfGlobal.CheckVoucherType(96, ref m_bWOCCReqd, ref m_bWOCompReqd);

            //if (m_bWOCCReqd == false)
            //{
            //    txtCCDPENo.Visible = false;
            //    lblCCDPENo.Visible = false;
            //}
            //else
            //{
            //    txtCCDPENo.Visible = true;
            //    lblCCDPENo.Visible = true;
            //}

            //if (m_bWOCompReqd == false)
            //{
            //    txtCompBVNo.Visible = false;
            //    lblCompNo.Visible = false;
            //}
            //else
            //{
            //    txtCompBVNo.Visible = true;
            //    lblCompNo.Visible = true;
            //}

            if (oVType.GenType == true)
            {
                if (m_sVoucherType == "  " || m_sVoucherType == "GE")
                {
                    txtLVNo.Text = oVType.VoucherNo;
                    barStaticItem1.Caption = oVType.VoucherNo;
                    txtLVNo.Visible = false;
                    lblDPENo.Visible = false;
                }
                else
                {
                    txtLVNo.Enabled = false;
                    txtLVNo.Visible = true;
                    lblDPENo.Visible = true;
                    txtLVNo.Text = oVType.VoucherNo;
                }
            }
            else
            {
                txtLVNo.Enabled = true;
                lblDPENo.Visible = true;
                barStaticItem1.Caption = "";
                txtLVNo.Text = "";
            }
        }
Пример #17
0
        private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (Convert.ToInt32(cboProj.EditValue) == -1)
                {
                    MessageBox.Show("Provide Project Type", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    cboProj.Focus();
                    return;
                }
                else if (Convert.ToInt32(cboFlatNo.EditValue) == -1)
                {
                    MessageBox.Show("Provide Flat Type", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    cboFlatNo.Focus();
                    return;
                }
                else if (txtBuyer.Text.Trim() == "")
                {
                    MessageBox.Show("Try another Project Type", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    cboProj.Focus();
                    return;
                }
                else if (Convert.ToInt32(cboNature.EditValue) == -1)
                {
                    MessageBox.Show("Provide Complaint Nature Type", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    cboNature.Focus();
                    return;
                }
                else if (Convert.ToInt32(cboExec.EditValue) == -1)
                {
                    MessageBox.Show("Provide Complaint Nature Type", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    cboExec.Focus();
                    return;
                }

                if (m_iComplaintId == 0)
                {
                    if (oVType.GenType == true)
                    {
                        oVType         = new BsfGlobal.VoucherType();
                        oVType         = BsfGlobal.GetVoucherNo(28, Convert.ToDateTime(dtCompDate.EditValue), 0, 0);
                        textCmpNo.Text = oVType.VoucherNo;
                    }
                }

                else
                {
                    if (oVType.PeriodWise == true)
                    {
                        oVType = new BsfGlobal.VoucherType();
                        if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(dtCompDate.EditValue)) == true)
                        {
                            oVType = BsfGlobal.GetVoucherNo(28, Convert.ToDateTime(dtCompDate.EditValue), 0, 0);
                        }
                    }
                }



                UpdateData();
                if (bSuccess == true)
                {
                    if (m_iComplaintId == 0)
                    {
                        ClearEntries();
                    }
                    else
                    {
                        //if (BsfGlobal.g_bWorkFlow == true)
                        //{
                        //    Close();
                        //    Cursor.Current = Cursors.WaitCursor;
                        //    frmComplaintRegister frmProg = new frmComplaintRegister();
                        //    frmProg.TopLevel = false;
                        //    frmProg.FormBorderStyle = FormBorderStyle.None;
                        //    frmProg.Dock = DockStyle.Fill;
                        //    frmComplaintRegister.m_oDW.Show();
                        //    frmComplaintRegister.t_panel.Controls.Clear();
                        //    frmComplaintRegister.t_panel.Controls.Add(frmProg);
                        //    frmProg.Show();
                        //    Cursor.Current = Cursors.Default;
                        //}
                        //else
                        //{
                        //    Close();
                        //}
                        Close();
                    }
                }
            }
            catch (Exception ex)
            {
                BsfGlobal.CustomException(ex.Message, ex.StackTrace);
            }
        }
Пример #18
0
        public void UpdateData()
        {
            try
            {
                if (radioGroup1.SelectedIndex == 0)
                {
                    m_sExtracharge = "N";
                }
                else
                {
                    m_sExtracharge = "Y";
                }

                if (cboProj.EditValue != null && cboNature.EditValue != null && Convert.ToInt32(cboNature.EditValue) > 0 && textCmpNo.Text != null && textCmpNo.Text != string.Empty)
                {
                    if (m_iComplaintId == 0)
                    {
                        string sAlert = "";
                        sAlert = cboNature.Text + " at " + cboProj.Text + " Flat No : " + cboFlatNo.Text;

                        //// --- Mail Sent to Tenant while Entering the complaint Entry -----
                        //Body = "<table style='background-color: #FFFFCC'><tr><td colspan='2' align='center' style='font-size: 20px; color: Maroon; border-style:groove;'>";
                        //Body += "<b> Complaint Entry Register</b></td></tr><tr><td colspan='2'></td></tr><tr style='width: 600px; height: 25px;'><td style='width: 200px;'>Project Name : ";
                        //Body += "</td><td style='width: 300px;'><b><i>" + cboProj.Text + "</i></b></td> </tr><tr><td style='width: 200px;'>Flat No : </td><td style='width: 300px;'><b><i>" + cboFlatNo.Text + "</i></b></td></tr>";
                        //Body += "<tr style='width: 600px; height: 25px;'><td style='width: 200px;'>Tenant Name : ";
                        //Body += " </td><td style='width: 300px;'><b><i>" + txtTenant.Text + "</i></b></td> </tr><tr><td style='width: 200px;'>Complaint No : </td><td style='width: 300px;'><b><i>" + textCmpNo.Text + "</i></b></td></tr>";
                        //Body += "<tr><td style='width: 200px;'>Nature Of Complaint :</td>";
                        //Body += "<td style='width: 300px;'><b><i>" + cboNature.Text + "</i></b></td></tr><tr><td style='width: 200px;'>Attented By :</td><td style='width: 300px;'><b><i>" + cboExec.Text + "</i></b></td>";
                        //Body += "</tr><tr><td style='width: 200px;'>Date Attented By :</td><td style='width: 300px;'><b><i>" + dtAttendDate.Value + "</i></b></td></tr><tr><td colspan='2'></td></tr>";
                        //Body += "<tr><td colspan='2' align='right' style='font-size: 14px; color: Maroon;'><b>[email protected]</b></td></tr> <tr><td colspan='2' align='right' style='font-size: 14px; color: Maroon; border-style: solid;'><i>Micromen.com</i></td></tr></table>";

                        //string sqlEmail;
                        //DataTable CheckEmail;
                        //sqlEmail = String.Format("select TenantName,Email from TenantDet where TenantId={0}", txtTenant.Tag);
                        //CheckEmail = new DataTable();
                        //CheckEmail = CommFun.FillRecord(sqlEmail);
                        //if (CheckEmail.Rows.Count >= 1)
                        //{
                        //    To = CheckEmail.Rows[0]["Email"].ToString();
                        //}
                        //// ---Mail End

                        if (m_sExtracharge == "Y" && cboFlatNo.EditValue != null)
                        {
                            // string sqlchk;
                            DataTable Check = new DataTable();
                            //sqlchk = String.Format("SELECT C.ComplaintId,C.CostCentreId,C.FlatId,C.LeadId,C.TenantId,C.NatureId, C.ExecutiveId,C.TransDate,C.AttDate DateAttented,E.EmployeeName AttendedBy,F.FlatNo,C1.CostCentreName, C.Remarks FROM Complaint_Entry C INNER JOIN FlatDetails F ON C.FlatId=F.FlatId INNER JOIN BuyerDetail B ON C.LeadId=B.LeadId INNER JOIN [{0}].dbo.OperationalCostCentre C1  ON C.CostCentreId=C1.CostCentreId INNER JOIN [{0}].dbo.Users E ON C.ExecutiveId=E.UserId where  F.FlatId={1} and C.chargetype='Y' ORDER BY DateAttented", BsfGlobal.g_sWorkFlowDBName, cboFlatNo.EditValue);
                            Check = ComplaintDetBL.CompliantCheck(Convert.ToInt32(cboFlatNo.EditValue));
                            if (Check.Rows.Count >= 1)
                            {
                                MessageBox.Show("Already submit the complaint", "Information", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                return;
                            }
                            else
                            {
                                oComtBO = new ComplaintDetBO();
                                ComplaintDetBO.CostCentreId = Convert.ToInt32(CommFun.IsNullCheck(cboProj.EditValue, CommFun.datatypes.vartypenumeric));
                                ComplaintDetBO.FlatId       = Convert.ToInt32(CommFun.IsNullCheck(cboFlatNo.EditValue, CommFun.datatypes.vartypenumeric));
                                ComplaintDetBO.BuyerId      = Convert.ToInt32(CommFun.IsNullCheck(txtBuyer.Tag, CommFun.datatypes.vartypenumeric));
                                ComplaintDetBO.TransDate    = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtCompDate.EditValue, CommFun.datatypes.VarTypeDate));
                                ComplaintDetBO.NatureId     = Convert.ToInt32(CommFun.IsNullCheck(cboNature.EditValue, CommFun.datatypes.vartypenumeric));
                                ComplaintDetBO.ExecutiveId  = Convert.ToInt32(CommFun.IsNullCheck(cboExec.EditValue, CommFun.datatypes.vartypenumeric));
                                ComplaintDetBO.AttDate      = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtAttendDate.EditValue, CommFun.datatypes.VarTypeDate));
                                ComplaintDetBO.Remarks      = CommFun.IsNullCheck(txtRemarks.Text, CommFun.datatypes.vartypestring).ToString();
                                ComplaintDetBO.complaintNo  = CommFun.IsNullCheck(textCmpNo.Text, CommFun.datatypes.vartypestring).ToString();
                                ComplaintDetBO.ChargeTYpe   = m_sExtracharge;
                                ComplaintDetBO.AttnRemarks  = CommFun.IsNullCheck(txtAttnRemark.Text, CommFun.datatypes.vartypestring).ToString();
                                ComplaintDetBO.ExeAttnId    = Convert.ToInt32(CommFun.IsNullCheck(cboAttnExec.EditValue, CommFun.datatypes.vartypenumeric));
                                bSuccess = ComplaintDetBL.InsertCompDetails(sAlert);
                                BsfGlobal.UpdateMaxNo(28, oVType, 0, 0);

                                // Body = "<table><tr><td colspan='2' align='center' style='font-size: 20px; color: Maroon; border-style:groove;'>";
                                // Body += "<b> Complaint Entry Register</b></td></tr><tr><td colspan='2'></td></tr><tr style='width: 600px; height: 25px;'><td style='width: 200px;'>Project Name : ";
                                // Body += "</td><td style='width: 300px;'><b><i>" + cboProj.Text + "</i></b></td> </tr><tr><td style='width: 200px;'>Flat No : </td><td style='width: 300px;'><b><i>" + cboFlatNo.Text + "</i></b></td></tr><tr><td style='width: 200px;'>Nature Of Complaint :</td>";
                                // Body += "<td style='width: 300px;'><b><i>" + cboNature.Text + "</i></b></td></tr><tr><td style='width: 200px;'>Attented By :</td><td style='width: 300px;'><b><i>" + cboExec.Text + "</i></b></td>";
                                // Body += "</tr><tr><td style='width: 200px;'>Date Attented By :</td><td style='width: 300px;'><b><i>" + dtAttendDate.Value + "</i></b></td></tr><tr><td colspan='2'></td></tr>";
                                //Body += "<tr><td colspan='2' align='right' style='font-size: 14px; color: Maroon;'><b>[email protected]</b></td></tr> <tr><td colspan='2' align='right' style='font-size: 14px; color: Maroon;'><i>Micromen.com</i></td></tr></table>";

                                //----- Mail Deliver---
                                // SendMail("Retrieve Complaint Entry", Body, true, "*****@*****.**", To, CC, BCC, "smtp.gmail.com", 587, "*****@*****.**", "micromen");
                            }
                        }
                        else
                        {
                            oComtBO = new ComplaintDetBO();
                            ComplaintDetBO.CostCentreId = Convert.ToInt32(CommFun.IsNullCheck(cboProj.EditValue, CommFun.datatypes.vartypenumeric));
                            ComplaintDetBO.FlatId       = Convert.ToInt32(CommFun.IsNullCheck(cboFlatNo.EditValue, CommFun.datatypes.vartypenumeric));
                            ComplaintDetBO.BuyerId      = Convert.ToInt32(CommFun.IsNullCheck(txtBuyer.Tag, CommFun.datatypes.vartypenumeric));
                            ComplaintDetBO.TransDate    = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtCompDate.EditValue, CommFun.datatypes.VarTypeDate));
                            ComplaintDetBO.NatureId     = Convert.ToInt32(CommFun.IsNullCheck(cboNature.EditValue, CommFun.datatypes.vartypenumeric));
                            ComplaintDetBO.ExecutiveId  = Convert.ToInt32(CommFun.IsNullCheck(cboExec.EditValue, CommFun.datatypes.vartypenumeric));
                            ComplaintDetBO.AttDate      = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtAttendDate.EditValue, CommFun.datatypes.VarTypeDate));
                            ComplaintDetBO.Remarks      = CommFun.IsNullCheck(txtRemarks.Text, CommFun.datatypes.vartypestring).ToString();
                            ComplaintDetBO.complaintNo  = CommFun.IsNullCheck(textCmpNo.Text, CommFun.datatypes.vartypestring).ToString();
                            ComplaintDetBO.ChargeTYpe   = m_sExtracharge;
                            ComplaintDetBO.AttnRemarks  = CommFun.IsNullCheck(txtAttnRemark.Text, CommFun.datatypes.vartypestring).ToString();
                            ComplaintDetBO.ExeAttnId    = Convert.ToInt32(CommFun.IsNullCheck(cboAttnExec.EditValue, CommFun.datatypes.vartypenumeric));
                            bSuccess = ComplaintDetBL.InsertCompDetails(sAlert);
                            BsfGlobal.UpdateMaxNo(28, oVType, 0, 0);
                            //----- Mail Deliver---
                            //SendMail("Retrieve Complaint Entry", Body, true, "*****@*****.**", To, CC, BCC, "smtp.gmail.com", 587, "*****@*****.**", "micromen");
                        }
                    }
                    else
                    {
                        oComtBO = new ComplaintDetBO();
                        ComplaintDetBO.ComplaintId  = m_iComplaintId;
                        ComplaintDetBO.CostCentreId = Convert.ToInt32(CommFun.IsNullCheck(cboProj.EditValue, CommFun.datatypes.vartypenumeric));
                        ComplaintDetBO.FlatId       = Convert.ToInt32(CommFun.IsNullCheck(cboFlatNo.EditValue, CommFun.datatypes.vartypenumeric));
                        ComplaintDetBO.BuyerId      = Convert.ToInt32(CommFun.IsNullCheck(txtBuyer.Tag, CommFun.datatypes.vartypenumeric));
                        ComplaintDetBO.TransDate    = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtCompDate.EditValue, CommFun.datatypes.VarTypeDate));
                        ComplaintDetBO.NatureId     = Convert.ToInt32(CommFun.IsNullCheck(cboNature.EditValue, CommFun.datatypes.vartypenumeric));
                        ComplaintDetBO.ExecutiveId  = Convert.ToInt32(CommFun.IsNullCheck(cboExec.EditValue, CommFun.datatypes.vartypenumeric));
                        ComplaintDetBO.AttDate      = String.Format("{0:dd-MMM-yyyy}", CommFun.IsNullCheck(dtAttendDate.EditValue, CommFun.datatypes.VarTypeDate));
                        ComplaintDetBO.Remarks      = CommFun.IsNullCheck(txtRemarks.Text, CommFun.datatypes.vartypestring).ToString();
                        ComplaintDetBO.complaintNo  = CommFun.IsNullCheck(textCmpNo.Text, CommFun.datatypes.vartypestring).ToString();
                        ComplaintDetBO.ChargeTYpe   = m_sExtracharge;
                        ComplaintDetBO.AttnRemarks  = CommFun.IsNullCheck(txtAttnRemark.Text, CommFun.datatypes.vartypestring).ToString();
                        ComplaintDetBO.ExeAttnId    = Convert.ToInt32(CommFun.IsNullCheck(cboAttnExec.EditValue, CommFun.datatypes.vartypenumeric));

                        if (Convert.ToDateTime(ComplaintDetBO.TransDate) != Convert.ToDateTime(dtCompDate.EditValue))
                        {
                            oVType = new BsfGlobal.VoucherType();
                            if (oVType.PeriodWise == true)
                            {
                                if (BsfGlobal.CheckPeriodChange(Convert.ToDateTime(ComplaintDetBO.TransDate), Convert.ToDateTime(dtCompDate.EditValue)) == true)
                                {
                                    oVType         = BsfGlobal.GetVoucherNo(28, Convert.ToDateTime(dtCompDate.EditValue), 0, 0);
                                    textCmpNo.Text = oVType.VoucherNo;
                                    BsfGlobal.UpdateMaxNo(28, oVType, 0, 0);
                                }
                            }
                        }
                        bSuccess = ComplaintDetBL.UpdateCompDetails();
                    }
                }
            }
            catch (Exception ex)
            {
                BsfGlobal.CustomException(ex.Message, ex.StackTrace);
            }
        }
Пример #19
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            bool bChange = false;

            if (Validation() == true)
            {
                if (m_lRegisterId == 0)
                {
                    UpdateRegNo();
                }
                else
                {
                    if (m_dOldDate != Convert.ToDateTime(dtpDate.Value))
                    {
                        if (oVType.PeriodWise == true)
                        {
                            if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(dtpDate.Value)))
                            {
                                oVType        = new BsfGlobal.VoucherType();
                                oVType        = BsfGlobal.GetVoucherNo(17, Convert.ToDateTime(dtpDate.Value), 0, 0);
                                txtRegNo.Text = oVType.VoucherNo;
                                bChange       = true;
                            }
                        }
                    }
                }

                if (CheckRegNo() == true)
                {
                    m_oRegister.RegisterId = m_lRegisterId;
                    m_oRegister.RegDate    = dtpDate.Value;
                    m_oRegister.RegNo      = txtRegNo.Text;
                    m_oRegister.VendorId   = m_lVendorId;

                    m_oRegister.Supply   = chkSupply.Checked;
                    m_oRegister.SFDate   = dtpSFDate.Value;
                    m_oRegister.STDate   = dtpSTDate.Value;
                    m_oRegister.SLife    = chkSLife.Checked;
                    m_oRegister.SGradeId = Convert.ToInt32(txtSGradeName.Tag);

                    m_oRegister.Contract = chkContract.Checked;
                    m_oRegister.CFDate   = dtpCFDate.Value;
                    m_oRegister.CTDate   = dtpCTDate.Value;
                    m_oRegister.CLife    = chkCLife.Checked;
                    m_oRegister.CGradeId = Convert.ToInt32(txtCGradeName.Tag);


                    m_oRegister.Service  = chkService.Checked;
                    m_oRegister.HFDate   = dtpHFDate.Value;
                    m_oRegister.HTDate   = dtpHTDate.Value;
                    m_oRegister.HLife    = chkHLife.Checked;
                    m_oRegister.HGradeId = Convert.ToInt32(txtHGradeName.Tag);

                    m_oRegister.Remarks = txtRemarks.Text;

                    if (m_lRegisterId == 0)
                    {
                        m_oRegister.InsertRegistration(m_oRegister);
                        BsfGlobal.UpdateMaxNo(17, oVType, 0, 0);
                        BsfGlobal.InsertAlert("Vendor-Register", "" + txtVendorName.Text + " - Registered Successfully", 0, BsfGlobal.g_sVendorDBName);
                        PopulateData();
                        MessageBox.Show("Registered Successfully!", "Vendor", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        m_oRegister.UpdateRegistration(m_oRegister);
                        if (bChange == true)
                        {
                            BsfGlobal.UpdateMaxNo(17, oVType, 0, 0);
                        }
                        MessageBox.Show("Registration Updated Successfully!", "Vendor", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    m_oRegUpdate.UpdateRegistration(m_lVendorId);
                    //this.Close();
                }
            }
        }
Пример #20
0
        private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (txtBrName.Text.Trim() == "")
            {
                MessageBox.Show("Provide Tenant Name", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txtBrName.Focus();
                return;
            }
            else if (txtAdd1.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Address", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txtAdd1.Focus();
                return;
            }
            else if (txtMobile.Text.Trim() == "")
            {
                MessageBox.Show("Provide MobileNo", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txtMobile.Focus();
                return;
            }
            else if (Convert.ToInt32(lookUpCity.EditValue) == -1)
            {
                MessageBox.Show("Select City", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                lookUpCity.Focus();
                return;
            }
            else if (Convert.ToInt32(lookUpPro.EditValue) == -1)
            {
                MessageBox.Show("Select Project", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                lookUpPro.Focus();
                return;
            }
            else if (Convert.ToInt32(lookUpBlock.EditValue) == -1 || Convert.ToInt32(lookUpBlock.EditValue) == 0)
            {
                MessageBox.Show("Select Block", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                lookUpBlock.Focus();
                return;
            }
            else if (Convert.ToInt32(lookUpUnit.EditValue) == -1 || Convert.ToInt32(lookUpUnit.EditValue) == 0)
            {
                MessageBox.Show("Select Flat", "PMS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                lookUpUnit.Focus();
                return;
            }

            if (m_iTenantId == 0)
            {
                if (oVType.GenType == true)
                {
                    oVType        = new BsfGlobal.VoucherType();
                    oVType        = BsfGlobal.GetVoucherNo(26, Convert.ToDateTime(dtCompDate.EditValue), 0, 0);
                    txtRefNo.Text = oVType.VoucherNo;
                }
            }
            else
            {
                if (oVType.PeriodWise == true)
                {
                    oVType = new BsfGlobal.VoucherType();
                    if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(dtCompDate.EditValue)) == true)
                    {
                        oVType = BsfGlobal.GetVoucherNo(26, Convert.ToDateTime(dtCompDate.EditValue), 0, 0);
                    }
                }
            }

            UpdateTenant();
            if (bSuccess == true)
            {
                if (m_iTenantId == 0)
                {
                    ClearEntries();
                }
                else
                {
                    //    if (BsfGlobal.g_bWorkFlow == true)
                    //    {
                    //        Close();
                    //        Cursor.Current = Cursors.WaitCursor;
                    //        frmTenantReg frmProg = new frmTenantReg();
                    //        frmProg.TopLevel = false;
                    //        frmProg.FormBorderStyle = FormBorderStyle.None;
                    //        frmProg.Dock = DockStyle.Fill;
                    //        frmTenantReg.m_oDW.Show();
                    //        frmTenantReg.t_panel.Controls.Clear();
                    //        frmTenantReg.t_panel.Controls.Add(frmProg);
                    //        frmProg.Show();
                    //        Cursor.Current = Cursors.Default;
                    //    }
                    //    else
                    //    {
                    //        Close();
                    //    }
                    Close();
                }
            }
        }
Пример #21
0
        private void btnOK_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (BsfGlobal.FindPermission("Stage Details-Add") == false)
            {
                MessageBox.Show("You don't have Rights to Stage Details-Add");
                return;
            }
            if (iStgId == 0)
            {
                if (oVType.GenType == true)
                {
                    oVType        = new BsfGlobal.VoucherType();
                    oVType        = BsfGlobal.GetVoucherNo(33, Convert.ToDateTime(Sdate.EditValue), 0, 0);
                    txtRefNo.Text = oVType.VoucherNo;
                }
            }

            else
            {
                if (oVType.PeriodWise == true)
                {
                    oVType = new BsfGlobal.VoucherType();
                    if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(Sdate.EditValue)) == true)
                    {
                        oVType = BsfGlobal.GetVoucherNo(33, Convert.ToDateTime(Sdate.EditValue), 0, 0);
                    }
                }
            }
            bool bAns = false;

            AssignStage();

            bAns = CostCentreBL.StageListFound(oU, iStgId);

            if (cboSBlock.EditValue == null || cboStage.EditValue == null)
            {
                return;
            }
            if (bAns == true)
            {
                MessageBox.Show("Stage Already Completed"); return;
            }


            if (Convert.ToInt32(cboSLevel.EditValue) == 0)
            {
                oU.LevelId = 0;
            }
            if (m_smode == "E")
            {
                if (cboSBlock.EditValue == null || cboStage.EditValue == null || cboStage.Text == "None")
                {
                    return;
                }

                if (Convert.ToDateTime(oU.StageDate) != Convert.ToDateTime(Sdate.EditValue))
                {
                    oVType = new BsfGlobal.VoucherType();
                    if (oVType.PeriodWise == true)
                    {
                        if (BsfGlobal.CheckPeriodChange(Convert.ToDateTime(oU.StageDate), Convert.ToDateTime(Sdate.EditValue)) == true)
                        {
                            oVType        = BsfGlobal.GetVoucherNo(33, Convert.ToDateTime(Sdate.EditValue), 0, 0);
                            txtRefNo.Text = oVType.VoucherNo;
                            BsfGlobal.UpdateMaxNo(33, oVType, 0, 0);
                        }
                    }
                }

                UnitDirBL.UpdateStage(oU, iStgId);

                //CommFun.InsertLog(DateTime.Now, "Stage Completion-Edit", "E", "Edit Stage Completion", BsfGlobal.g_lUserId, 0, m_iCCId, 0, BsfGlobal.g_sCRMDBName);
                BsfGlobal.InsertLog(DateTime.Now, "Stage Completion-Edit", "E", "Edit Stage Completion", iStgId, m_iCCId, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId);
                this.Close();
            }
            else
            {
                UnitDirBL.InsertStage(oU);

                BsfGlobal.UpdateMaxNo(33, oVType, 0, 0);
                clearstage();
                //CommFun.InsertLog(DateTime.Now, "Stage Completion-Add", "N", "Add Stage Completion", BsfGlobal.g_lUserId, 0, m_iCCId, 0, BsfGlobal.g_sCRMDBName);
                BsfGlobal.InsertLog(DateTime.Now, "Stage Completion-Add", "N", "Add Stage Completion", iStgId, m_iCCId, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId);
            }
        }