Пример #1
0
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string strMsg = string.Empty;

            if (e.CommandName == "cmdedit")
            {
                Response.Redirect("TripEntry.aspx?TripI=" + e.CommandArgument, true);
            }
            if (e.CommandName == "cmddelete")
            {
                TripEntryDAL      obj = new TripEntryDAL();
                clsAccountPosting objclsAccountPosting = new clsAccountPosting();
                Int32             intValue             = obj.Delete(Convert.ToInt32(e.CommandArgument));
                obj = null;
                if (intValue > 0)
                {
                    objclsAccountPosting.DeleteAccountPosting(Convert.ToInt32(e.CommandArgument), "TRP");
                    this.BindGrid();
                    strMsg = "Record deleted successfully.";
                    txtReceiptNo.Focus();
                }
                else
                {
                    if (intValue == -1)
                    {
                        strMsg = "Record can not be deleted. It is in use.";
                    }
                    else
                    {
                        strMsg = "Record not deleted.";
                    }
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
            }
        }
        private bool PostIntoAccounts(double Amount, Int64 intDocIdno, string strDocType, double dblRndOff, Int32 intCompIdno, Int32 intUserIdno, Int32 intUserType, Int32 intVchrForIdno, Int32 YearIdno)
        {
            #region Variables Declaration...

            Int64 intVchrIdno = 0;
            Int64 intValue    = 0;
            hidpostingmsg.Value = string.Empty;
            clsAccountPosting objclsAccountPosting = new clsAccountPosting();
            double            dblNetAmnt           = 0;
            double            dblDiscAmnt          = 0;

            DateTime?dtPBillDate = null;
            DateTime?dtBankDate  = null;
            if (string.IsNullOrEmpty(txtInstDate.Text) == false)
            {
                dtBankDate = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtInstDate.Text));
            }
            #endregion

            #region Account link Validations...

            //clsAccountPosting objclsAccountPosting = new clsAccountPosting();
            //   tblAcntLink objAcntLink = objclsAccountPosting.GetAccountLinkData();
            //    if (objAcntLink == null)
            //    {
            //       hidpostingmsg.Value = " Account link is not defined. Kindly define.";
            //    }
            //    else
            //    {

            //    }


            #endregion
            PaymentToOwnDAL obj       = new PaymentToOwnDAL();
            Int32           IAcntIdno = 0;
            // Int32 ILType = obj.selectTruckType(Convert.ToInt32(ddlTruckNo.SelectedValue)); //Convert.ToInt32(clsDataAccessFunction.ExecuteScaler("select Lorry_type from LorryMast where Lorry_Idno=" + Convert.ToInt32(cmbTruckNo.SelectedValue) + "", Tran, Program.DataConn));
            //if (ILType == 1)
            //{
            //IAcntIdno = Convert.ToInt32(ddlDriverName.SelectedValue);
            //}
            //else
            //{
            IAcntIdno = Convert.ToInt32((string.IsNullOrEmpty((hidDriverIdno.Value)) ? "0" : hidDriverIdno.Value));
            //}
            if (Request.QueryString["q"] == null)
            {
                intValue = 1;
            }
            else
            {
                intValue = objclsAccountPosting.DeleteAccountPosting(intDocIdno, strDocType);
            }
            if (intValue > 0)
            {
                //IAcntIdno = Convert.ToInt32(ddlDriverName.SelectedValue);
                IAcntIdno = 0;

                Int64 VchrNo = objclsAccountPosting.GetMaxVchrNo(2, 0, Convert.ToInt32(ddldateRange.SelectedValue));

                intValue = objclsAccountPosting.InsertInVchrHead(
                    Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text.Trim())),
                    1,
                    Convert.ToInt32((ddlRcptTyp.SelectedIndex == -1) ? 0 : Convert.ToInt32(ddlRcptTyp.SelectedValue)),
                    "Receipt No :" + Convert.ToString(txtRcptNo.Text) + " Receipt Date: " + txtDate.Text.Trim() + "Total Paid Amount :" + Convert.ToDouble(txtAmount.Text.Trim().Replace("'", "")) + "",
                    true,
                    0,
                    strDocType,
                    IAcntIdno,
                    0,
                    0,
                    Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text.Trim())),
                    ((VchrNo == 0) ? 1 : VchrNo),
                    0,
                    YearIdno,
                    0, 0);
                if (intValue > 0)
                {
                    intVchrIdno = intValue;
                    intValue    = 0; IAcntIdno = Convert.ToInt32((ddlRcptTyp.SelectedIndex == -1) ? 0 : Convert.ToInt32(ddlRcptTyp.SelectedValue));

                    intValue = objclsAccountPosting.InsertInVchrDetl(
                        intVchrIdno,
                        Convert.ToInt32((ddlRcptTyp.SelectedIndex == -1) ? 0 : Convert.ToInt32(ddlRcptTyp.SelectedValue)),
                        "Receipt No :" + Convert.ToString(txtRcptNo.Text) + " Receipt Date: " + txtDate.Text.Trim() + "Total Amount Paid :" + Convert.ToDouble(txtAmount.Text.Trim().Replace("'", "")) + "  ",
                        Amount,
                        Convert.ToByte(1),
                        Convert.ToByte(0),
                        Convert.ToString(txtInstNo.Text),
                        true,
                        dtBankDate,
                        Convert.ToString(ddlCustmerBank.SelectedValue), 0);

                    if (intValue > 0)
                    {
                        intVchrIdno = intValue;
                        intValue    = 0;
                        intValue    = objclsAccountPosting.InsertInVchrDetl(
                            intVchrIdno,
                            Convert.ToInt32(hidDriverIdno.Value),
                            "Receipt No :" + Convert.ToString(txtRcptNo.Text) + " Receipt Date: " + txtDate.Text.Trim() + "Total Paid Received :" + Convert.ToDouble(txtAmount.Text.Trim().Replace("'", "")) + "  ",
                            Amount,
                            Convert.ToByte(2),
                            Convert.ToByte(0),
                            Convert.ToString(txtInstNo.Text),
                            false,
                            dtBankDate,
                            Convert.ToString(ddlCustmerBank.SelectedValue), 0);
                    }
                    else
                    {
                        return(false);
                    }
                    #region VchrIdDetl Posting...

                    if (intValue > 0)
                    {
                        intValue = 0;
                        intValue = objclsAccountPosting.InsertInVchrIdDetl(intVchrIdno, intDocIdno, strDocType);
                        if (intValue == 0)
                        {
                            return(false);
                        }
                    }

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

            #region Deallocate variables...

            objclsAccountPosting = null;
            return(true);

            #endregion
        }
        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
        }