示例#1
0
    public void fillwareselect()
    {
        chkappentry.Visible = false;
        DataTable appri = ClsAccountAppr.Apprreuqired();

        if (appri.Rows.Count > 0)
        {
            ViewState["AccRS"] = "ACC";
            int kn = ClsAccountAppr.Allowchkappr(ddlwarehouse.SelectedValue);
            if (kn == 1)
            {
                chkappentry.Visible = true;
            }
        }
        else
        {
            ViewState["AccRS"] = "";
        }
        lblMSG.Text          = "";
        ImageButton3.Enabled = true;
        btnedit.Enabled      = true;
        DataTable dtpaacc = select("Select * from AccountPageRightAccess where cid='" + Session["Comid"] + "' and Access='1' and AccType='0'");

        if (dtpaacc.Rows.Count > 0)
        {
            ImageButton3.Enabled = false;
            btnedit.Enabled      = false;
            DataTable dtrc = select(" select Accountingpagerightwithdesignation.*  from Accountingpagerightwithdesignation inner join DesignationMaster on Accountingpagerightwithdesignation.DesignationId=DesignationMaster.DesignationMasterId " +
                                    " inner join DepartmentmasterMNC on DepartmentmasterMNC.Id=DesignationMaster.DeptId where DesignationId='" + Session["DesignationId"] + "' and  DepartmentmasterMNC.whid='" + ddlwarehouse.SelectedValue + "'");
            if (dtrc.Rows.Count > 0)
            {
                if (Convert.ToInt32(dtrc.Rows[0]["AccessRight"]) == 0)
                {
                    lblMSG.Text = "Sorry,you are not access right for this business";
                }
                else if (Convert.ToInt32(dtrc.Rows[0]["AccessRight"]) == 2)
                {
                    if (Convert.ToInt32(dtrc.Rows[0]["Edit_Right"]) == 1)
                    {
                        btnedit.Enabled = true;
                    }
                    else if (Convert.ToInt32(dtrc.Rows[0]["Insert_Right"]) == 1)
                    {
                        ImageButton3.Enabled = true;
                    }
                }
                else
                {
                    ImageButton3.Enabled = true;
                    btnedit.Enabled      = true;
                }
            }
            else
            {
                lblMSG.Text = "Sorry,you are not access right for this business";
            }
        }
        if (Request.QueryString["docid"] != null)
        {
            chkdoc.Checked = false;
            chkdoc.Visible = false;
        }
        else
        {
            chkdoc.Visible = true;
        }

        DataTable ds = MainAcocount.SelectEntrynumber("3", ddlwarehouse.SelectedValue);

        if (ds.Rows.Count > 0)
        {
            if (ds.Rows[0]["Id"].ToString() != "")
            {
                i = Convert.ToInt32(ds.Rows[0]["Id"]) + 1;
            }
            else
            {
                i = 1;
            }
        }
        else
        {
            i = 1;
        }
        txtEntryNo.Text = Convert.ToString(i);

        accountfill();
    }
示例#2
0
    public void checkCrDr()
    {
        int       accesin = 0;
        DataTable dtdr    = select("Select  AccountAddDataRequireTbl.* from AccountAddDataRequireTbl  where  Compid='" + Session["Comid"] + "' and Access='1'");

        if (dtdr.Rows.Count > 0)
        {
            DataTable dtd = select("Select Distinct AccountPageDataAddDesignationRight.* from AccountPageDataAddDesignationRight  where   DesignationId='" + Convert.ToString(Session["DesignationId"]) + "'");

            if (dtd.Rows.Count > 0)
            {
                if (Convert.ToInt32(dtd.Rows[0]["Accessbus"]) == 0)
                {
                    accesin = 1;
                }
                else if (Convert.ToInt32(dtd.Rows[0]["Accessbus"]) == Convert.ToInt32(ddlwarehouse.SelectedValue))
                {
                    accesin = 1;
                }
            }
        }

        else
        {
            accesin = 1;
        }
        //int  accesin = ClsAccountAppr.AccessInsert(ddlwarehouse.SelectedValue);

        if (accesin == 1)
        {
            bool access = UserAccess.Usercon("TranctionMaster", "", "Tranction_Master_Id", "", "", "compid", "TranctionMaster");
            if (access == true)
            {
                decimal totalCr = 0;
                decimal totalDr = 0;
                foreach (GridViewRow gdr in GridView1.Rows)
                {
                    if (gdr.Cells[2].Text == "Credit")
                    {
                        totalCr = totalCr + Convert.ToDecimal(gdr.Cells[3].Text);
                    }
                    else
                    {
                        totalDr = totalDr + Convert.ToDecimal(gdr.Cells[3].Text);
                    }
                }

                if (totalCr == totalDr)
                {
                    try
                    {
                        DataTable ds9 = MainAcocount.SelectEntrynumber("3", ddlwarehouse.SelectedValue);

                        if (ds9.Rows.Count > 0)
                        {
                            if (ds9.Rows[0]["Id"].ToString() != "")
                            {
                                i = Convert.ToInt32(ds9.Rows[0]["Id"]) + 1;
                            }
                            else
                            {
                                i = 1;
                            }
                        }
                        else
                        {
                            i = 1;
                        }



                        int id = MainAcocount.InsertTransactionMaster(Convert.ToDateTime(txtDate.Text), i.ToString(), "3", Convert.ToInt32(Session["userid"]), totalDr, ddlwarehouse.SelectedValue);
                        if (i > 0)
                        {
                            ViewState["tid"] = id.ToString();


                            int tsid = MainAcocount.Sp_Insert_TranctionMasterSuppliment(id, "", 0, 0, 0);
                            foreach (GridViewRow gdr1 in GridView1.Rows)
                            {
                                if (gdr1.Cells[2].Text == "Credit")
                                {
                                    int tdid = MainAcocount.Sp_Insert_Tranction_Details1(0, Convert.ToInt32(gdr1.Cells[0].Text), 0, Convert.ToDecimal(gdr1.Cells[3].Text), id, Convert.ToString(gdr1.Cells[4].Text.Replace(" ", "")), Convert.ToDateTime(txtDate.Text), ddlwarehouse.SelectedValue);
                                }
                                else
                                {
                                    int tdid = MainAcocount.Sp_Insert_Tranction_Details1(Convert.ToInt32(gdr1.Cells[0].Text), 0, Convert.ToDecimal(gdr1.Cells[3].Text), 0, id, Convert.ToString(gdr1.Cells[4].Text.Replace(" ", "")), Convert.ToDateTime(txtDate.Text), ddlwarehouse.SelectedValue);
                                }
                            }
                            DataTable dtapprequirment = ClsAccountAppr.Apprreuqired();
                            if (dtapprequirment.Rows.Count > 0)
                            {
                                ClsAccountAppr.AccountAppMaster(ddlwarehouse.SelectedValue, ViewState["tid"].ToString(), chkappentry.Checked);
                            }
                            lblMSG.Visible = true;
                            lblMSG.Text    = "Record inserted successfully";
                        }
                        else
                        {
                            lblMSG.Visible = true;
                            lblMSG.Text    = "Record is not added";
                        }


                        txtDate.Text      = System.DateTime.Now.ToShortDateString();
                        lblentrytype.Text = "Journal Entry";

                        DataTable ds56 = MainAcocount.SelectEntrynumber("3", ddlwarehouse.SelectedValue);


                        if (ds56.Rows.Count > 0)
                        {
                            if (ds56.Rows[0]["Id"].ToString() != "")
                            {
                                i = Convert.ToInt32(ds56.Rows[0]["Id"]) + 1;
                            }
                            else
                            {
                                i = 1;
                            }
                        }
                        else
                        {
                            i = 1;
                        }
                        txtEntryNo.Text = Convert.ToString(i);
                        lbldise.Text    = Convert.ToString(i);



                        GridView1.DataSource = null;
                        GridView1.DataBind();
                        ViewState["dt"] = null;

                        if (Request.QueryString["docid"] != null)
                        {
                            inserdocatt();
                        }
                        else
                        {
                            if (chkdoc.Checked == true)
                            {
                                entry();
                                // ModalPopupExtender1.Show();
                                // filldoc();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        lblMSG.Visible = true;
                        lblMSG.Text    = "Error:" + ex.Message.ToString();
                    }
                }
                else
                {
                    if (totalCr > totalDr)
                    {
                        ddlcrdr.SelectedIndex = ddlcrdr.Items.IndexOf(ddlcrdr.Items.FindByText("Debit"));
                        txtAmount.Text        = Convert.ToString(totalCr - totalDr);
                    }
                    else if (totalCr < totalDr)
                    {
                        ddlcrdr.SelectedIndex = ddlcrdr.Items.IndexOf(ddlcrdr.Items.FindByText("Credit"));
                        txtAmount.Text        = Convert.ToString(totalDr - totalCr);
                    }
                    txtmemo.Focus();
                    txtmemo.Text   = "";
                    lblMSG.Visible = true;
                    lblMSG.Text    = "Please check the total amount of all account debited must equal the total amount of all account credited";
                }
                clear();
            }
            else
            {
                lblMSG.Visible = true;
                lblMSG.Text    = "Sorry, You are not permitted for greater record as per price plan";
            }
        }
        else
        {
            lblMSG.Visible = true;
            lblMSG.Text    = "You are not permited to insert record for this page.";
        }
    }