private bool RecPostIntoAccounts(double AdvAmount, Int64 intDocIdno, string strDocType, double dblRndOff, Int32 intCompIdno, Int32 intUserIdno, Int32 intUserType, Int32 intVchrForIdno, Int32 YearIdno, Int32 TruckIdno, string InstDate, string InstNo, Int32 DriverIdno, string strDate, Int32 intChlnNo, Int32 intRcptType, Int32 intCustBIdno, double dGrossAmnt, double dCommissionAmnt, double dTdsAmnt, double dDiesel)
        {
            #region Variables Declaration...
            Int64             intVchrIdno = 0; Int64 intValue = 0; Int32 IAcntIdno = 0; DateTime?dtBankDate = null;
            clsAccountPosting objclsAccountPosting = new clsAccountPosting();
            ChlnBookingDAL    objAcnt = new ChlnBookingDAL();
            BindDropdownDAL   objDal  = new BindDropdownDAL();
            #endregion
            #region Start Ac/Posting.........
            AcntLinkDS = objAcnt.DtAcntDS(ApplicationFunction.ConnectionString());
            DsHire     = objAcnt.DsHireAcnt(ApplicationFunction.ConnectionString());
            DataSet dsLD = objDal.GetLorryDetails(ApplicationFunction.ConnectionString(), "GetLorryDetails", TruckIdno, strDate);
            if (dsLD != null && dsLD.Tables.Count > 0 && dsLD.Tables[0].Rows.Count > 0)
            {
                Int32  intLtype   = string.IsNullOrEmpty(dsLD.Tables[0].Rows[0]["Lorry_Type"].ToString()) ? 0 : Convert.ToInt32(dsLD.Tables[0].Rows[0]["Lorry_Type"]);
                string strLorryNo = Convert.ToString(dsLD.Tables[0].Rows[0]["Lorry_No"]);
                Int32  PartyIdno  = Convert.ToInt32(dsLD.Tables[0].Rows[0]["Acnt_Idno"]);
                IAcntIdno = PartyIdno;
                #region Account link Validations...

                if (AcntLinkDS == null || AcntLinkDS.Rows.Count <= 0)
                {
                    ShowMessageErr("Account link is not defined. Kindly define.");
                    return(false);
                }

                ICAcnt_Idno = Convert.ToInt32(Convert.ToString(AcntLinkDS.Rows[0]["CAcnt_Idno"]) == "" ? 0 : Convert.ToInt32(AcntLinkDS.Rows[0]["CAcnt_Idno"]));
                if (ICAcnt_Idno <= 0)
                {
                    ShowMessageErr("Commission Account is not defined. Kindly define.");
                    return(false);
                }
                if (DsHire == null || DsHire.Rows.Count <= 0)
                {
                    ShowMessageErr("Transport Account is not defined. Kindly define.");
                    return(false);
                }
                else
                {
                    IHireAcntIdno = Convert.ToInt32(DsHire.Rows[0]["HireAccountID"]);
                }
                IntTDSAcntIdno = Convert.ToInt32(Convert.ToString(AcntLinkDS.Rows[0]["TDS_Idno"]) == "" ? 0 : Convert.ToInt32(AcntLinkDS.Rows[0]["TDS_Idno"]));
                if (IntTDSAcntIdno <= 0)
                {
                    ShowMessageErr("TDS Account is not defined. Kindly define.");
                    return(false);
                }
                //IntDieselAcc_Idno = Convert.ToInt32(ddlAcntLink.SelectedValue);
                //if (IntDieselAcc_Idno <= 0)
                //{
                //    hidpostingmsg.Value = "Diesel Account is not defined. Kindly define.";
                //    return false;
                //}

                #endregion
                #region Amount Posting............
                intValue = objclsAccountPosting.DeleteAccountPosting(intDocIdno, strDocType);
                #region Commission Account Posting ................
                if (dCommissionAmnt > 0)
                {
                    if (intValue > 0)
                    {
                        Int64 VchrNo = objclsAccountPosting.GetMaxVchrNo(4, 0, YearIdno);
                        intValue = objclsAccountPosting.InsertInVchrHead(
                            Convert.ToDateTime(ApplicationFunction.mmddyyyy(strDate)),
                            4,
                            0,
                            "Challan No: " + Convert.ToString(intChlnNo) + " Challan Date: " + strDate + " Lorry: " + strLorryNo + "Commission Posting",
                            true,
                            0,
                            strDocType,
                            0,
                            0,
                            Convert.ToInt64(intChlnNo),
                            ApplicationFunction.GetIndianDateTime().Date,
                            VchrNo,
                            0,
                            YearIdno,
                            0, intUserIdno);
                        if (intValue > 0)
                        {
                            intVchrIdno = intValue;
                            #region Commission Amount  Posting...
                            intValue = 0;
                            /*Insert In VchrDetl*/
                            intValue = objclsAccountPosting.InsertInVchrDetl(
                                intVchrIdno,
                                Convert.ToInt64(ICAcnt_Idno),
                                "Challan No: " + Convert.ToString(intChlnNo) + " Challan Date: " + strDate + " Lorry: " + strLorryNo + "Commission Posting",
                                dCommissionAmnt,
                                Convert.ToByte(1),
                                Convert.ToByte(0),
                                "",
                                true,
                                null, //please check here if date is Blank
                                "", 0);
                            if (intValue > 0)
                            {
                                intValue = 0;
                                intValue = objclsAccountPosting.InsertInVchrDetl(
                                    intVchrIdno,
                                    Convert.ToInt64(PartyIdno),
                                    "Challan No: " + Convert.ToString(intChlnNo) + " Challan Date: " + strDate + " Lorry: " + strLorryNo + "Commission Posting",
                                    Convert.ToDouble(dCommissionAmnt),
                                    Convert.ToByte(2),
                                    Convert.ToByte(0),
                                    "",
                                    false,
                                    null,     //please check here if date is Blank
                                    "", 0);

                                if (intValue == 0)
                                {
                                    return(false);
                                }

                                if (intValue > 0)
                                {
                                    intValue = 0; /*Insert In VchrIdDetl*/
                                    intValue = objclsAccountPosting.InsertInVchrIdDetl(intVchrIdno, intDocIdno, strDocType);
                                    if (intValue == 0)
                                    {
                                        return(false);
                                    }
                                }
                            }
                            else
                            {
                                return(false);
                            }

                            #endregion
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                #endregion
                #region  TDS Account Posting..................

                if (dTdsAmnt > 0 && IAcntIdno > 0)
                {
                    if (intValue > 0)
                    {
                        Int64 VchrNo = objclsAccountPosting.GetMaxVchrNo(4, 0, YearIdno);
                        intValue = objclsAccountPosting.InsertInVchrHead(
                            Convert.ToDateTime(ApplicationFunction.mmddyyyy(strDate)), 4, 0, "Challan No: " + Convert.ToString(intChlnNo) + " Challan Date: " + strDate + " Lorry: " + strLorryNo + "TDS Posting",
                            true, 0, strDocType, 0, 0, Convert.ToInt64(intChlnNo), ApplicationFunction.GetIndianDateTime().Date, VchrNo, 0,
                            YearIdno, 0, intUserIdno);
                        if (intValue > 0)
                        {
                            intVchrIdno = intValue;

                            #region TDS Account Posting .........

                            intValue = 0;
                            /*Insert In VchrDetl*/
                            intValue = objclsAccountPosting.InsertInVchrDetl(
                                intVchrIdno, Convert.ToInt64(IAcntIdno), "Challan No: " + Convert.ToString(intChlnNo) + " Challan Date: " + strDate + " Lorry: " + strLorryNo + "TDS Posting",
                                dTdsAmnt, Convert.ToByte(2), Convert.ToByte(0), "", true, null, //please check here if date is Blank
                                "", 0);
                            if (intValue > 0)
                            {
                                intValue = 0;
                                intValue = objclsAccountPosting.InsertInVchrDetl(
                                    intVchrIdno, IntTDSAcntIdno, "Challan. No: " + Convert.ToString(intChlnNo) + " Challan. Date: " + strDate + " Lorry: " + strLorryNo + "TDS Posting",
                                    Convert.ToDouble(dTdsAmnt), Convert.ToByte(1), Convert.ToByte(0), "", false,
                                    null,     //please check here if date is Blank
                                    "", 0);

                                if (intValue == 0)
                                {
                                    return(false);
                                }

                                if (intValue > 0)
                                {
                                    intValue = 0; /*Insert In VchrIdDetl*/
                                    intValue = objclsAccountPosting.InsertInVchrIdDetl(intVchrIdno, intDocIdno, strDocType);
                                    if (intValue == 0)
                                    {
                                        return(false);
                                    }
                                }
                            }
                            else
                            {
                                return(false);
                            }

                            #endregion
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }

                #endregion

                #endregion
                objclsAccountPosting = null;
                return(true);
            }
            else
            {
                objclsAccountPosting = null;
                return(true);
            }
            #endregion
        }