private void UpdateDB() { Edit_Info master = (Edit_Info)this.Master; TextBox TextBoxName = (TextBox)master.FindControl("TextBoxName"); TextBox TextBoxDOB = (TextBox)master.FindControl("TextBoxDOB"); TextBox TextBoxNIDNo = (TextBox)master.FindControl("TextBoxNIDNo"); TextBox TextBoxPhone = (TextBox)master.FindControl("TextBoxPhone"); TextBox TextBoxAddress = (TextBox)master.FindControl("TextBoxAddress"); TextBox TextBoxEmail = (TextBox)master.FindControl("TextBoxEmail"); RadioButtonList RadioButtonListGender = (RadioButtonList)master.FindControl("RadioButtonListGender"); RadioButtonList RadioButtonListNIDType = (RadioButtonList)master.FindControl("RadioButtonListNIDType"); FileUpload fileup = (FileUpload)master.FindControl("FileUploadProPic"); //FileUpload Nomfileup = (FileUpload)master.FindControl("FileUploadNomProPic"); Label fileErr = (Label)master.FindControl("FileErr"); string fileEx = System.IO.Path.GetExtension(fileup.FileName); string name = TextBoxName.Text + TextBoxPhone.Text; string filePath = Server.MapPath("~/Images/ProPic/" + name + fileEx); if (fileup.HasFile) { if (fileEx.ToLower() != ".jpeg" && fileEx.ToLower() != ".jpg" && fileEx.ToLower() != ".png") { fileErr.Text = "Only .jpeg, .jpg and .png file is allowed"; } else { int filesize = fileup.PostedFile.ContentLength; if (filesize > 4194304) { fileErr.Text = "File should be less than 4mb"; } else { fileup.SaveAs(filePath); } } } string fileExNom = System.IO.Path.GetExtension(FileUploadNomProPic.FileName); string nameNom = TextBoxNomName.Text + TextBoxNomPhone.Text; string filePathNom = Server.MapPath("~/Images/ProPic/" + nameNom + fileExNom); if (FileUploadNomProPic.HasFile) { if (fileExNom.ToLower() != ".jpeg" && fileExNom.ToLower() != ".jpg" && fileExNom.ToLower() != ".png") { fileErr.Text = "Only .jpeg, .jpg and .png file is allowed"; } else { int filesize = FileUploadNomProPic.PostedFile.ContentLength; if (filesize > 4194304) { fileErr.Text = "File should be less than 4mb"; } else { FileUploadNomProPic.SaveAs(filePathNom); } } } LoadDB("Customer", "CustomerId", 10000000, 1); SqlDataAdapter adapter = (SqlDataAdapter)Cache["Adapter"]; DataSet ds = (DataSet)Cache["DataSet"]; //DataRow dr = ds.Tables["Customer"].NewRow(); // dr["ChangeId"] = "400001"; DataRow[] row = ds.Tables["Customer"].Select("CustomerId = 10000000"); int status = 10000000; foreach (DataRow dr in row) { if (status.Equals(dr["CustomerId"])) { dr["CustomerName"] = TextBoxName.Text; dr["DOB"] = TextBoxDOB.Text; //Session["UserId"]; dr["Gender"] = RadioButtonListGender.SelectedValue; //Session["UserName"]; dr["NIDNO"] = TextBoxNIDNo.Text; dr["NIDType"] = RadioButtonListNIDType.SelectedValue; dr["Phone"] = TextBoxPhone.Text; dr["Address"] = TextBoxAddress.Text; //Session["UserId"]; dr["Email"] = TextBoxEmail.Text; //Session["UserName"]; dr["ProPic"] = "~/Images/ProPic/" + name + fileEx; dr["NominyName"] = TextBoxNomName.Text; dr["NominyDOB"] = TextBoxNomDOB.Text; //Session["UserId"]; dr["NominyGender"] = RadioButtonListNomGender.SelectedValue; //Session["UserName"]; dr["NominyNIDNO"] = TextBoxNomNIDNo.Text; dr["NominyNIDType"] = RadioButtonListNomNIDType.SelectedValue; dr["NominyPhone"] = TextBoxNomPhone.Text; dr["NominyAddress"] = TextBoxNomAddress.Text; //Session["UserId"]; dr["NominyEmail"] = TextBoxNomEmail.Text; //Session["UserName"]; dr["NominyProPic"] = "~/Images/ProPic/" + nameNom + fileExNom; Cache["Dataset"] = ds; ds = (DataSet)Cache["DataSet"]; adapter = (SqlDataAdapter)Cache["Adapter"]; adapter.Update(ds.Tables["Customer"]); } } }
/*private void setData() * { * LoadDB("BankStatus", "StatusId", 1, 1); * SqlDataAdapter adapter = (SqlDataAdapter)Cache["Adapter"]; * DataSet ds = (DataSet)Cache["DataSet"]; * DataRow[] dr = ds.Tables["BankStatus"].Select("StatusId = '1'"); * int status = 1; * foreach (DataRow row in dr) * { * if (status.Equals(row["StatusId"])) * { * TextBoxLoanStatus.Text = (string)row["LoanStatus"]; * TextBoxNotice.Text = (string)row["Notice"]; * } * } * Cache["Dataset"] = ds; * } * private void UpdateDB() * { * LoadDB("BankStatus", "StatusId", 1, 1); * SqlDataAdapter adapter = (SqlDataAdapter)Cache["Adapter"]; * DataSet ds = (DataSet)Cache["DataSet"]; * DataRow[] dr = ds.Tables["BankStatus"].Select("StatusId = '1'"); * int status = 1; * foreach (DataRow row in dr) * { * if (status.Equals(row["StatusId"])) * { * row["LoanStatus"] = TextBoxLoanStatus.Text; * row["Notice"] = TextBoxNotice.Text; * } * } * Cache["Dataset"] = ds; * ds = (DataSet)Cache["DataSet"]; * adapter = (SqlDataAdapter)Cache["Adapter"]; * adapter.Update(ds.Tables["BankStatus"]); * } */ private void InsertDB() { Registration master = (Registration)this.Master; TextBox TextBoxName = (TextBox)master.FindControl("TextBoxName"); TextBox TextBoxDOB = (TextBox)master.FindControl("TextBoxDOB"); TextBox TextBoxNIDNo = (TextBox)master.FindControl("TextBoxNIDNo"); TextBox TextBoxPhone = (TextBox)master.FindControl("TextBoxPhone"); TextBox TextBoxAddress = (TextBox)master.FindControl("TextBoxAddress"); TextBox TextBoxEmail = (TextBox)master.FindControl("TextBoxEmail"); RadioButtonList RadioButtonListGender = (RadioButtonList)master.FindControl("RadioButtonListGender"); RadioButtonList RadioButtonListNIDType = (RadioButtonList)master.FindControl("RadioButtonListNIDType"); FileUpload fileup = (FileUpload)master.FindControl("FileUploadProPic"); //FileUpload Nomfileup = (FileUpload)master.FindControl("FileUploadNomProPic"); Label fileErr = (Label)master.FindControl("FileErr"); string fileEx = System.IO.Path.GetExtension(fileup.FileName); string name = TextBoxName.Text + TextBoxPhone.Text; string filePath = Server.MapPath("~/Images/ProPic/" + name + fileEx); if (fileup.HasFile) { if (fileEx.ToLower() != ".jpeg" && fileEx.ToLower() != ".jpg" && fileEx.ToLower() != ".png") { fileErr.Text = "Only .jpeg, .jpg and .png file is allowed"; } else { int filesize = fileup.PostedFile.ContentLength; if (filesize > 4194304) { fileErr.Text = "File should be less than 4mb"; } else { fileup.SaveAs(filePath); } } } string fileExNom = System.IO.Path.GetExtension(FileUploadNomProPic.FileName); string nameNom = TextBoxNomName.Text + TextBoxNomPhone.Text; string filePathNom = Server.MapPath("~/Images/ProPic/" + nameNom + fileExNom); if (FileUploadNomProPic.HasFile) { if (fileExNom.ToLower() != ".jpeg" && fileExNom.ToLower() != ".jpg" && fileExNom.ToLower() != ".png") { fileErr.Text = "Only .jpeg, .jpg and .png file is allowed"; } else { int filesize = FileUploadNomProPic.PostedFile.ContentLength; if (filesize > 4194304) { fileErr.Text = "File should be less than 4mb"; } else { FileUploadNomProPic.SaveAs(filePathNom); } } } LoadDB("Customer", "CustomerId", 10000000, 1); SqlDataAdapter adapter = (SqlDataAdapter)Cache["Adapter"]; DataSet ds = (DataSet)Cache["DataSet"]; DataRow dr = ds.Tables["Customer"].NewRow(); // dr["ChangeId"] = "400001"; dr["CustomerName"] = TextBoxName.Text; dr["DOB"] = TextBoxDOB.Text; //Session["UserId"]; dr["Gender"] = RadioButtonListGender.SelectedValue; //Session["UserName"]; dr["NIDNO"] = TextBoxNIDNo.Text; dr["NIDType"] = RadioButtonListNIDType.SelectedValue; dr["Phone"] = TextBoxPhone.Text; dr["Address"] = TextBoxAddress.Text; //Session["UserId"]; dr["Email"] = TextBoxEmail.Text; //Session["UserName"]; dr["ProPic"] = "~/Images/ProPic/" + name + fileEx; dr["JoinDate"] = DateTime.Now; dr["LeaveDate"] = "Pigeon"; //Session["UserName"]; dr["Password"] = passgenaretor(); dr["AddedById"] = 2000; dr["AddedByName"] = "Pigeon"; //Session["UserName"]; dr["AccountType"] = RadioButtonList1.SelectedValue; dr["NominyName"] = TextBoxNomName.Text; dr["NominyDOB"] = TextBoxNomDOB.Text; //Session["UserId"]; dr["NominyGender"] = RadioButtonListNomGender.SelectedValue; //Session["UserName"]; dr["NominyNIDNO"] = TextBoxNomNIDNo.Text; dr["NominyNIDType"] = RadioButtonListNomNIDType.SelectedValue; dr["NominyPhone"] = TextBoxNomPhone.Text; dr["NominyAddress"] = TextBoxNomAddress.Text; //Session["UserId"]; dr["NominyEmail"] = TextBoxNomEmail.Text; //Session["UserName"]; dr["NominyProPic"] = "~/Images/ProPic/" + nameNom + fileExNom; dr["TotalBalance"] = "500"; ds.Tables["Customer"].Rows.Add(dr); Cache["Dataset"] = ds; ds = (DataSet)Cache["DataSet"]; adapter = (SqlDataAdapter)Cache["Adapter"]; adapter.Update(ds.Tables["Customer"]); alert(); }