Пример #1
0
        protected void btnSaveRecpt_Click(object sender, EventArgs e)
        {
            try
            {
                recId = int.Parse(txtRecNo.Text);
                if (validate())
                {
                    CustomValidator1.IsValid = true;
                    CustomValidator1.ErrorMessage = "";
                    int intReceiptNo = Convert.ToInt32(txtRecNo.Text);
                    DateTime dateReceiptDate = Convert.ToDateTime(txtRecDate.Text);
                    int mode = 0;
                    int intClId = Convert.ToInt32(txtClId.Text);
                    int intGrpId;
                    if (txtGrpId.Text == "")
                        intGrpId = 0;
                    else
                        intGrpId = Convert.ToInt32(txtGrpId.Text);
                    string strpaytyp = DRpDwnLstPmntTyp.SelectedItem.Text;
                    double doubleAmt = Convert.ToDouble(txtAmt.Text);
                    double doubleTDS = Convert.ToDouble(txtTDSReadOnly.Text);
                    double doubledisc = Convert.ToDouble(txtDisc.Text);
                    string strBnkNm = txtBnkNm.Text;
                    string strChqDftNo = txtChqOrDftNo.Text;
                    DateTime dtChqDftDate = Convert.ToDateTime(txtChqOrDftDt.Text);
                    int intAgainstBills = 0;
                    if (chkAgainstBills.Checked == true)
                        intAgainstBills = 1;
                    else intAgainstBills = 0;
                    double doublebalAmt = double.Parse(txtBalamt.Text);
                    int intTDSCertRecvd = 0;
                    if (chkbxTDSCertRecvd.Checked == true)
                        intTDSCertRecvd = 1;
                    else intTDSCertRecvd = 0;
                    string strCmmnts = txtCoommnts.Text;
                    string strClNm = DrplstClRec.SelectedItem.Text;
                    string strSubGrpNm = txtSubGrpNm.Text;
                    int intIsDel = 0;
                    if (rbtnlstIsDel.SelectedItem.Text == "Yes")
                        intIsDel = 1;
                    else
                        intIsDel = 0;
                    double BillAmt = Convert.ToDouble(txtBllAmt.Text);
                    double TDSPerc = Convert.ToDouble(txtTDSPerc.Text);
                    int intApp = 0;
                    if (chkbxAppRecpt.Checked == true)
                        intApp = 1;
                    else
                        intApp = 0;
                    BLAddReceipt bladdRec = new BLAddReceipt();
                    if (Request.QueryString["ReceiptId"] != null)
                    {
                        mode = 1;
                        RecId = int.Parse(Request.QueryString["ReceiptId"]);
                        bladdRec.UpdateReceipt(RecId, dateReceiptDate, intGrpId, strpaytyp, doubleAmt, doubleTDS, doubledisc, strBnkNm, strChqDftNo, dtChqDftDate, intAgainstBills, doublebalAmt, intTDSCertRecvd, strCmmnts, strSubGrpNm, intIsDel, BillAmt, TDSPerc, intApp);
                        updateAdjustAmount(mode, RecId);
                        DrplstClRec.Enabled = true;
                        lblResult.Visible = true;

                        lblResult.Text = "Receipt Details are Updated Successfully";
                        BtnClearRec.Enabled = true;
                        recId++;
                        txtRecNo.Text = recId.ToString();
                        ClearAll();
                    }
                    else
                    {
                        bladdRec.addReceipt(intReceiptNo, dateReceiptDate, intClId, intGrpId, strpaytyp, doubleAmt, doubleTDS, doubledisc, strBnkNm, strChqDftNo, dtChqDftDate, intAgainstBills, doublebalAmt, intTDSCertRecvd, strCmmnts, strClNm, strSubGrpNm, intIsDel, BillAmt, TDSPerc, intApp);

                        updateAdjustAmount(mode, recId);
                        recId++;
                        txtRecNo.Text = recId.ToString();
                        foreach (GridViewRow gvrow in GrdVwInvoice.Rows)
                        {
                            if (gvrow.RowType == DataControlRowType.DataRow)
                            {
                                CheckBox chkSel = gvrow.Cells[0].FindControl("chksel") as CheckBox;
                                Label invid = (gvrow.Cells[0].FindControl("lblInvoiceId") as Label);
                                //Label lblamt = (gvrow.Cells[0].FindControl("lblamt") as Label);
                                if (chkSel.Checked)
                                {
                                    int InvoiceId = int.Parse(invid.Text);
                                    //int ReceiptId = intReceiptNo;
                                    string constr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;

                                    SqlConnection con = new SqlConnection(constr);
                                    SqlCommand cmd = new SqlCommand("SaveReciptInvoices_SP", con);
                                    cmd.CommandType = CommandType.StoredProcedure;
                                    cmd.Parameters.AddWithValue("@ReceiptId", recId);
                                    cmd.Parameters.AddWithValue("@InvoiceId", InvoiceId);

                                    con.Open();
                                    cmd.ExecuteNonQuery();
                                    con.Close();
                                }
                            }
                        }
                        lblResult.Visible = true;
                        lblResult.Text = "Receipt Details are Added Successfully";
                        DrplstClRec.Enabled = true;
                        ClearAll();

                    }
                }
                else
                {
                    CustomValidator1.IsValid = false;
                    CustomValidator1.ErrorMessage = "*";
                    CustomValidator1.ToolTip = "Enter Proper Amt";
                }
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }
Пример #2
0
        protected void DrplstClRec_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                lblResult.Text = "";
                string ClNm = DrplstClRec.SelectedItem.Text;

                BLAddReceipt bladdRec = new BLAddReceipt();
                SqlDataReader dr = bladdRec.GetClientIdByNm1(ClNm);
                if (dr.HasRows)
                {
                    dr.Read();
                    txtClId.Text = Convert.ToString(dr.GetInt32(0));
                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SqlDataReader dr;
                BLAddReceipt blViewRec = new BLAddReceipt();
                if ((HttpContext.Current.Session["LoginId"]) == null)
                {
                    Response.Redirect("~/Login.aspx");
                }
                txtChqOrDftDt.Text = System.DateTime.Now.ToShortDateString();
                dr = blViewRec.GetMaxRecId();
                if (dr.Read())
                {
                    if (dr.IsDBNull(0))
                    {
                        recid = 0;
                    }
                    else
                    {
                        recid = dr.GetInt32(0);
                        dr.Close();

                    }
                }
                recid++;
                if (!Page.IsPostBack)
                {
                    txtRecNo.Text = recid.ToString();
                    dr = blViewRec.getClientRec();

                    if (dr.HasRows)
                    {
                        while (dr.Read())
                            DrplstClRec.Items.Add(dr.GetString(0));
                        DrplstClRec.Items.Insert(0, new ListItem("--Select--", "-1"));
                        dr.Close();
                    }
                    txtRecDate.Text = System.DateTime.Now.ToShortDateString();
                    txtChqOrDftDt.Text = System.DateTime.Now.ToShortDateString();

                    if (Request.QueryString["ReceiptId"] != null)
                    {

                        RecId = int.Parse(Request.QueryString["ReceiptId"]);
                        SqlDataReader drGetRecDet = blViewRec.GetRecDetForUpdate(RecId);
                        if (drGetRecDet.HasRows == true)
                        {
                            while (drGetRecDet.Read())
                            {
                                txtRecNo.Text = (drGetRecDet.GetInt32(1)).ToString();
                                DateTime recdate = drGetRecDet.GetDateTime(2);
                                txtRecDate.Text = recdate.ToShortDateString();
                                txtClId.Enabled = false;

                                txtClId.Text = drGetRecDet.GetInt32(3).ToString();
                                int ClientId = int.Parse(txtClId.Text);
                                txtGrpId.Text = drGetRecDet.GetInt32(4).ToString();
                                string paymenttype = drGetRecDet.GetString(5);
                                DRpDwnLstPmntTyp.SelectedValue = paymenttype;
                                txtAmt.Text = (drGetRecDet.GetSqlMoney(6)).ToString();
                                txtTDSReadOnly.Text = drGetRecDet.GetSqlMoney(7).ToString();
                                txtDisc.Text = drGetRecDet.GetSqlMoney(8).ToString();
                                txtBnkNm.Text = drGetRecDet.GetString(9);
                                txtChqOrDftNo.Text = drGetRecDet.GetString(10).ToString();
                                DateTime chequedftdate = drGetRecDet.GetDateTime(11);
                                txtChqOrDftDt.Text = chequedftdate.ToShortDateString();
                                bool isonacc = drGetRecDet.GetBoolean(12);
                                if (isonacc == true)
                                    chkAgainstBills.Checked = true;
                                else
                                    chkAgainstBills.Checked = false;
                                txtBalamt.Text = drGetRecDet.GetSqlMoney(13).ToString();
                                bool tdsCerRecceived = drGetRecDet.GetBoolean(14);
                                if (tdsCerRecceived == true)
                                    chkbxTDSCertRecvd.Checked = true;
                                else
                                    chkbxTDSCertRecvd.Checked = false;
                                txtCoommnts.Text = drGetRecDet.GetString(15);
                                DrplstClRec.Enabled = false;
                                DrplstClRec.SelectedValue = drGetRecDet.GetString(16);
                                txtSubGrpNm.Text = drGetRecDet.GetString(17);
                                bool isdel = drGetRecDet.GetBoolean(18);
                                if (isdel == true)
                                    rbtnlstIsDel.Items.FindByValue("Yes").Selected = true;
                                else
                                    rbtnlstIsDel.Items.FindByValue("No").Selected = true;
                                txtBllAmt.Text = drGetRecDet.GetDecimal(19).ToString();
                                txtTDSPerc.Text = drGetRecDet.GetDecimal(20).ToString();
                                int app = drGetRecDet.GetInt32(21);
                                if (app == 1)
                                    chkbxAppRecpt.Checked = true;
                                else
                                    chkbxAppRecpt.Checked = false;

                                //if against bills is true then diaplay invoice details in gridview
                                if (chkAgainstBills.Checked == true)
                                {
                                    SqlDataReader drGetInvForGirdview = blViewRec.GetInvoiceByAddRec1(ClientId, update);
                                    Panel1.Visible = true;
                                    GrdVwInvoice.Visible = true;
                                    GrdVwInvoice.DataSource = drGetInvForGirdview;
                                    GrdVwInvoice.DataBind();
                                }
                            }
                            drGetRecDet.Close();
                            BtnClearRec.Enabled = false;
                        }
                    }
                }
                else
                {
                    lblAmtMsg.Text = "";
                    CalendarExtender1.SelectedDate = DateTime.ParseExact(txtChqOrDftDt.Text, CalendarExtender1.Format, null);
                    CalendarExtender2.SelectedDate = DateTime.ParseExact(txtRecDate.Text, CalendarExtender2.Format, null);
                }
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }
Пример #4
0
 protected void chkAgainstBills_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         if (Request.QueryString["ReceiptId"] != null)
         {
             if (chkAgainstBills.Checked == true)
             {
                 Panel1.Visible = true;
                 GrdVwInvoice.Visible = true;
                 BLAddReceipt bladdInvce = new BLAddReceipt();
                 int ClId = Convert.ToInt32(txtClId.Text);
                 getInvByAddRec(ClId, update);
             }
         }
         if (chkAgainstBills.Checked == true)
         {
             update = 0;
             Panel1.Visible = true;
             GrdVwInvoice.Visible = true;
             int ClId = Convert.ToInt32(txtClId.Text);
             getInvByAddRec(ClId, update);
         }
         else
             Panel1.Visible = false;
     }
     catch (Exception ex)
     {
         lblCatchError.Text = ex.Message.ToString();
     }
 }