public async Task <IActionResult> Create(bankmasterIndexViewModel model)
        {
            if (ModelState.IsValid)
            {
                var objcategory = new bankmaster
                {
                    id                = model.id,
                    bankname          = model.bankname,
                    bankifsccode      = model.bankifsccode,
                    bankbranch        = model.bankbranch,
                    accountno         = model.accountno,
                    accountholdername = model.accountholdername,
                    isdeleted         = false,
                    isactive          = false
                };

                _unitofWork.bankmaster.Add(objcategory);
                _unitofWork.Save();
                TempData["success"] = "Record Save successfully";
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        
        bankmaster objbank = new bankmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
        objbank.bankmaster_SRNO = -1;
        objbank.bankmaster_LEDGERID = -1;
        objbank.bankmaster_ACCOUNTNAME=txtaccountname.Text.Trim().ToString();
        objbank.bankmaster_ACCOUNTNO = txtactno.Text.Trim().ToString();
        objbank.bankmaster_CITYNAME=ddlcity.SelectedItem.Text;
        objbank.bankmaster_STATENAME=ddlstate.SelectedItem.Text;
        objbank.bankmaster_BANKBRANCHNAME = txtbranchname.Text.Trim().ToString();
        objbank.bankmaster_BANKNAME = ddlbank.SelectedItem.Text;
        objbank.bankmaster_MICRCODE = txtmicrcode.Text.Trim().ToString();
        objbank.bankmaster_IFSCCODE = txtifsccode.Text.Trim().ToString();
        objbank.bankmaster_ADDRESS = txtaddress.Text.Trim().ToString();
        objbank.bankmaster_BRANCHID = General.Parse<int>(Session["cmpid"].ToString());
        objbank.bankmaster_STATUS=0;
        if (objbank.Insert(true, "bankmaster"))
        {
            string sqlmax = "SELECT MAX(SRNO) AS SRNO FROM BANKMASTER BM WHERE STATUS=0 AND ACCOUNTNAME='" + txtaccountname.Text.Trim().ToString()+"'";
            Handler hdnmax = new Handler();
            DataTable dtmax = hdnmax.GetTable(sqlmax);

            string sqlrel = "SELECT RELATIONSHIPID FROM PERSONALTABLE PT WHERE PT.FIRSTNAME='BANK ACCOUNT' AND BRANCHID=" + Session["branchid"].ToString();
            Handler hdnrel = new Handler();
            DataTable dtrel = hdnrel.GetTable(sqlrel);
            if (dtrel.Rows.Count > 0)
            {
                Handler hdngroup = new Handler();
                DataTable dtgroup = hdngroup.GetTable("SELECT GROUPID FROM ACCOUNTGROUP AG WHERE GROUPNAME='BANK ACCOUNT' AND BRANCHID=0");
                personalrelation objpersonalrelation = new personalrelation(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                objpersonalrelation.personalrelation_SRNO = -1;
                objpersonalrelation.personalrelation_RELATIONSHIPID = General.Parse<int>(dtrel.Rows[0]["RELATIONSHIPID"].ToString());
                objpersonalrelation.personalrelation_ASSOSIATEDBRANCH = General.Parse<int>(Session["branchid"].ToString());
                objpersonalrelation.personalrelation_ASSOSIATEDFEILD = ddlbank.SelectedItem.Text;
                objpersonalrelation.personalrelation_GROUPID = General.Parse<int>(dtgroup.Rows[0]["GROUPID"].ToString());
                objpersonalrelation.personalrelation_STATUS = 0;
                if (objpersonalrelation.Insert(true, "personalrelation"))
                {
                    Handler hdnledger = new Handler();
                    string sqlban="SELECT MAX(PR.SRNO) AS LEDGERID FROM PERSONALRELATION PR WHERE PR.GROUPID=" + dtgroup.Rows[0]["GROUPID"].ToString().Trim() + " AND PR.ASSOSIATEDFEILD='" + ddlbank.SelectedItem.Text.Trim() + "' AND PR.RELATIONSHIPID=" + dtrel.Rows[0]["RELATIONSHIPID"].ToString().Trim();
                    DataTable dtledger = hdnledger.GetTable(sqlban);
                    
                    bankmaster objbank1 = new bankmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                    objbank1.bankmaster_SRNO = -1;
                    objbank1.bankmaster_LEDGERID = General.Parse<int>(dtledger.Rows[0]["LEDGERID"].ToString());
                    objbank1.bankmaster_BRANCHID = -1;
                    objbank1.bankmaster_STATUS = -1;
                    string condition = "BRANCHID=" + Session["branchid"].ToString() + " AND BANKNAME='" + ddlbank.SelectedItem.Text.Trim() + "' AND ACCOUNTNO='" + txtactno.Text.Trim().ToString()+"'";
                    if (objbank1.Insert(false, "bankmaster", condition))
                    {
                    }
                }
            }
            //MessageBox("Bank Created Successfully");
            //Response.Redirect("bankaccountdetails.aspx?ID=1&BANKID=" + dtmax.Rows[0][0].ToString().Trim());
            Response.Redirect("bankaccountlist.aspx?ID=1");
        }
    }
    public void BindBank(Int64 BankId)
    {
        bankmaster objbankmaster = (new Cls_bankmaster_b().SelectById(BankId));

        if (objbankmaster != null)
        {
            txtBankName.Text          = objbankmaster.bankname;
            txtIFSC.Text              = objbankmaster.bankifsccode;
            txtBankBranch.Text        = objbankmaster.bankbranch;
            txtAccountNo.Text         = objbankmaster.accountno;
            txtAccountHolderName.Text = objbankmaster.accountholdername;
        }
    }
        public bankmaster SelectById(Int64 bankid)
        {
            SqlDataAdapter da;
            DataSet        ds            = new DataSet();
            bankmaster     objbankmaster = new bankmaster();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "bankmaster_SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@bankid", bankid);
                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0] != null)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                {
                                    objbankmaster.bankid            = Convert.ToInt32(ds.Tables[0].Rows[0]["bankid"]);
                                    objbankmaster.bankname          = Convert.ToString(ds.Tables[0].Rows[0]["bankname"]);
                                    objbankmaster.bankifsccode      = Convert.ToString(ds.Tables[0].Rows[0]["bankifsccode"]);
                                    objbankmaster.bankbranch        = Convert.ToString(ds.Tables[0].Rows[0]["bankbranch"]);
                                    objbankmaster.accountno         = Convert.ToString(ds.Tables[0].Rows[0]["accountno"]);
                                    objbankmaster.accountholdername = Convert.ToString(ds.Tables[0].Rows[0]["accountholdername"]);
                                    objbankmaster.balance           = Convert.ToDecimal(ds.Tables[0].Rows[0]["balance"]);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objbankmaster);
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64      Result        = 0;
        bankmaster objbankmaster = new bankmaster();

        objbankmaster.bankname          = txtBankName.Text.Trim();
        objbankmaster.bankifsccode      = txtIFSC.Text.Trim();
        objbankmaster.bankbranch        = txtBankBranch.Text.Trim();
        objbankmaster.accountno         = txtAccountNo.Text.Trim();
        objbankmaster.accountholdername = txtAccountHolderName.Text.Trim();
        objbankmaster.balance           = Convert.ToDecimal(txtbalance.Text.Trim());

        if (Request.QueryString["id"] != null)
        {
            objbankmaster.bankid = Convert.ToInt32(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            Result = (new Cls_bankmaster_b().Update(objbankmaster));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/managebank.aspx?mode=u"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Bank Not Updated";
                BindBank(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)));
            }
        }
        else
        {
            Result = (new Cls_bankmaster_b().Insert(objbankmaster));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/managebank.aspx?mode=i"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Bank Not Inserted";
            }
        }
    }
        public Int64 Update(bankmaster objbankmaster)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "bankmaster_Update";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@bankid";
                param.Value         = objbankmaster.bankid;
                param.SqlDbType     = SqlDbType.Int;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@bankname", objbankmaster.bankname);
                cmd.Parameters.AddWithValue("@bankifsccode", objbankmaster.bankifsccode);
                cmd.Parameters.AddWithValue("@bankbranch", objbankmaster.bankbranch);
                cmd.Parameters.AddWithValue("@accountno", objbankmaster.accountno);
                cmd.Parameters.AddWithValue("@accountholdername", objbankmaster.accountholdername);
                cmd.Parameters.AddWithValue("@balance", objbankmaster.balance);

                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {

        bankmaster objbank = new bankmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
        objbank.bankmaster_SRNO = -1;
        objbank.bankmaster_LEDGERID = -1;
        objbank.bankmaster_ACCOUNTNAME = txtaccountname.Text.Trim().ToString();
        objbank.bankmaster_ACCOUNTNO = txtactno.Text.Trim().ToString();
        objbank.bankmaster_CITYNAME = ddlcity.SelectedItem.Text;
        objbank.bankmaster_STATENAME = ddlstate.SelectedItem.Text;
        objbank.bankmaster_BANKBRANCHNAME = txtbranchname.Text.Trim().ToString();
        objbank.bankmaster_BANKNAME = ddlbank.SelectedItem.Text;
        objbank.bankmaster_MICRCODE = txtmicrcode.Text.Trim().ToString();
        objbank.bankmaster_IFSCCODE = txtifsccode.Text.Trim().ToString();
        objbank.bankmaster_ADDRESS = txtaddress.Text.Trim().ToString();
        objbank.bankmaster_BRANCHID = General.Parse<int>(Session["cmpid"].ToString());
        objbank.bankmaster_STATUS = General.Parse<int>(ddlstatus.SelectedValue.Trim().ToString());
        string condition = "SRNO=" + ViewState["BANKID"].ToString().Trim();
        if (objbank.Insert(false, "bankmaster", condition))
        {
            
            Response.Redirect("bankaccountlist.aspx?ID=2");
        }
    }