Пример #1
0
        protected void btn_update_Click(object sender, EventArgs e)
        {
            try
            {
                using (var db = new THFinanceEntities())
                {
                    int           id  = Convert.ToInt32(lbl_id.Text);
                    tbl_Guarantor tbl = (from s in db.tbl_Guarantor
                                         where s.GuarantorId.Equals(id)
                                         select s).SingleOrDefault();
                    tbl.GuarantorAddress     = txt_guaranteeaddresseee.Text;
                    tbl.GuarantorborrowerId  = Convert.ToInt32(ddl_borrwer.SelectedValue);
                    tbl.GuarantorDesignation = txt_guaranteedesignation.Text;
                    tbl.GuarantorFatherName  = txt_guaranteefathername.Text;
                    tbl.GuarantorName        = txt_guaranteename.Text;
                    tbl.GuarantorPhone       = txt_guaranteephone.Text;
                    Stream fs  = txt_guaranteeprooffile.PostedFile.InputStream;
                    Stream fs2 = txt_guaranteephoto.PostedFile.InputStream;

                    BinaryReader br     = new BinaryReader(fs);
                    BinaryReader br2    = new BinaryReader(fs2);
                    Byte[]       bytes  = br.ReadBytes((Int32)fs.Length);
                    Byte[]       bytes2 = br2.ReadBytes((Int32)fs.Length);
                    tbl.Guarantorphoto     = bytes2;
                    tbl.GuarantorProof     = bytes;
                    tbl.GuarantorProoftype = txt_guaranteeproof.Value;
                    db.SaveChanges();
                    clearfields();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        protected void btn_login_Click(object sender, EventArgs e)
        {
            try
            {
                using (THFinanceEntities context = new THFinanceEntities())
                {
                    tbl_Guarantor tbl = new tbl_Guarantor();

                    tbl.GuarantorName       = txt_guaranteename.Text;
                    tbl.GuarantorFatherName = txt_guaranteefathername.Text;
                    tbl.GuarantorborrowerId = Convert.ToInt32(ddl_borrwer.SelectedValue);
                    Stream fs  = txt_guaranteeprooffile.PostedFile.InputStream;
                    Stream fs2 = txt_guaranteephoto.PostedFile.InputStream;

                    BinaryReader br     = new BinaryReader(fs);
                    BinaryReader br2    = new BinaryReader(fs2);
                    Byte[]       bytes  = br.ReadBytes((Int32)fs.Length);
                    Byte[]       bytes2 = br2.ReadBytes((Int32)fs.Length);
                    tbl.GuarantorAddress = txt_guaranteeaddresseee.Text;
                    tbl.GuarantorPhone   = txt_guaranteephone.Text;
                    tbl.GuarantorProof   = bytes;
                    //txt_guaranteeprooffile.PostedFile.SaveAs(Server.MapPath("~/Uploads") + tbl.GuarantorProof);
                    tbl.GuarantorProoftype = txt_guaranteeproof.Value;
                    tbl.G_createdBy        = Convert.ToInt32(Session["UserID"]);
                    tbl.G_createdDate      = DateTime.Now;
                    tbl.Guarantorphoto     = bytes2;
                    txt_guaranteephoto.PostedFile.SaveAs(Server.MapPath("~/Uploads") + tbl.Guarantorphoto);
                    // tbl.G_modifiedBy = 1;
                    // tbl.G_modifiedDate = null;
                    context.tbl_Guarantor.Add(tbl);
                    context.SaveChanges();
                    Response.Write("<script>alert('Sucessfully Saved')</script>");
                    clearfields();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }