private void BindGridViewCustomer() { try { if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlCommand cmd = new SqlCommand("USP_SelectInContactInformation", conn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter adp = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adp.Fill(ds); GridViewCustomer.DataSource = ds; GridViewCustomer.DataBind(); lbltotalcount.Text = GridViewCustomer.Rows.Count.ToString(); } catch (SqlException ex) { ShowMessage(ex.Message); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } }
private void RefreshData() { var data = imsdb.Customers.OrderByDescending(d => d.Id).ToList(); GridViewCustomer.DataSource = data; GridViewCustomer.DataBind(); }
protected void BindGridList() { GridViewCustomer.DataSource = ELCustomerList; GridViewCustomer.DataBind(); //GridViewCustomer.HeaderRow.TableSection = TableRowSection.TableFooter; GridViewCustomer.HeaderRow.TableSection = TableRowSection.TableHeader; }
private void RefreshForm() { try { ClearValues(); LoadLkCustomerTypes(); LoadLkSearchCustomerType(); LoadLkSearchCustomerGroup(sCustomerTypeId); LoadLkCustomerGroup(sCustomerTypeId); LoadCustomer(); sCustomerId = ClassProperty.sCustomerId; if (sCustomerId != 0) { GetData(sCustomerId); GridViewCustomer.FocusedRowHandle = GridViewCustomer.LocateByValue("CustomerName", stCustomerName); } if (ClassProperty.IsCusType == 0) { BtnSelect.Visible = false; } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }
public void loadDataUser() { //user = new User(); //GridViewCustomer.DataSource = user.selectUser(); users = new UserDic(); users.selectUsers(); GridViewCustomer.DataSource = users.Values; GridViewCustomer.DataBind(); }
protected void btnSearch_Click(object sender, EventArgs e) { if (DropDownList1.SelectedIndex == 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Error", "alert('Please select a field')", true); } else { GridViewCustomer.DataSource = null; GridViewCustomer.DataBind(); string Field = DropDownList1.SelectedValue.ToString(); string SearchVal = txfSearch.Text.ToString(); string AllFields = "HomeAssistPanicSOS,MemberStatus,PolicyType,MemberNo,Policy_Inception_date,CancellationDate,Title,Name,Surname,IDNumber,PassportNumber,TelHome,TelWork,TelOther,MainEmailAddress,AltEmailAddress,ResidentialAddressComplexNo,ResidentialAddressComplexName,ResidentialAddressStreetNo,ResidentialAddressStreetName,ResidentialAddressSuburb,ResidentialAddressPOcode,ResidentialAddressProvince"; string adp = $"SELECT { AllFields} FROM Client WHERE[{ Field}] LIKE '%{SearchVal}%'"; if (Field == "TelHome") { adp = $"SELECT {AllFields} FROM Client WHERE TelHome LIKE '%{SearchVal}%' OR TelWork LIKE '%{SearchVal}%' OR TelOther LIKE '%{SearchVal}%'"; } if (Field == "Name") { adp = $"SELECT {AllFields} FROM Client WHERE Name LIKE '%{SearchVal}%' OR Surname LIKE '%{SearchVal}%'"; } var output = database.FetchQuery(adp); try { GridViewCustomer.DataSource = output; GridViewCustomer.DataBind(); foreach (GridViewRow dr in GridViewCustomer.Rows) { try { DateTime dts1 = Convert.ToDateTime(dr.Cells[4].Text); dr.Cells[4].Text = dts1.ToString("dd MMM yyyy"); } catch (Exception) { } } if (output.Count > 0) { try { SendLogData(output.Count + "", Field, SearchVal, DateTime.Now.ToString("dd MMM yyyy hh:mm:ss")); } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Error", "alert('Unable To send Data " + ex + "')", true); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Error", "alert('Could not load due to " + ex + "')", true); } } }
private void BtnSave_Click(object sender, EventArgs e) { // 16 5 : สิทธิ์ใช้งานหน้าสมาชิก บันทึกข้อมูลสมาชิก int AuthorizeId = 16; if (SQLAuthorized.CheckAuthorized(ClassProperty.permisRoleId, AuthorizeId) == false) { SQLAuthorized.AlertAuthorized("สิทธิ์ใช้งานหน้าสมาชิก", "ไม่มีสิทธิ์บันทึกข้อมูลสมาชิก"); return; } if (stCustomerTypeId == 0) { XtraMessageBox.Show("กรุณาระบุประเภทลูกค้า !", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); LkCustomerTypes.ShowPopup(); return; } if (LkCustomerGroup.EditValue == null) { XtraMessageBox.Show("กรุณาระบุกลุ่มลูกค้า !", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); LkCustomerGroup.ShowPopup(); return; } if (TxtCustomerName.Text.Trim() == string.Empty) { XtraMessageBox.Show("กรุณาระบุชื่อลูกค้า !", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtCustomerName.Focus(); return; } sCustomerCode = TxtCustomerCode.Text; sCustomerName = TxtCustomerName.Text; if (SaveData() == true) { LoadCustomer(); GridViewCustomer.FocusedRowHandle = GridViewCustomer.LocateByValue("CustomerName", TxtCustomerName.Text); sCustomerId = Convert.ToInt32(GridViewCustomer.GetFocusedRowCellValue("CustomerId")); if (CheckCustomerPrice(sCustomerId)) { GetData(sCustomerId); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["typeid"].ToString() != "2") { Response.Redirect("~/Login/Login.aspx"); } } catch (Exception) { Response.Redirect("~/Login/Login.aspx"); } if (!IsPostBack) { var data = imsdb.Customers.OrderByDescending(d => d.Id).ToList(); GridViewCustomer.DataSource = data; GridViewCustomer.DataBind(); } }
protected void BindGridViewCustomer() { sqlConnectionOBJ.ConnectionString = "Data Source=DESKTOP-P0QRTM4;Initial Catalog=DatabaseSystems8490;Integrated Security=True"; try { sqlConnectionOBJ.Open(); sqlCommandOBJ.CommandText = "SELECT * FROM Customer"; sqlCommandOBJ.Connection = sqlConnectionOBJ; sqlDataAdapterOBJ.SelectCommand = sqlCommandOBJ; dataSetOBJ = new DataSet(); sqlDataAdapterOBJ.Fill(dataSetOBJ, "Customer"); //we are expecting a DataSet/ResultSet back if (dataSetOBJ.Tables[0].Rows.Count > 0) //run if there's more than one row in the dataset { GridViewCustomer.DataSource = dataSetOBJ; GridViewCustomer.DataBind(); } else { } } catch (SqlException ex) { lblMessage.Visible = true; lblMessage.Text = "SqlException*** ERROR*** \n " + ex.Message; throw; } finally { sqlConnectionOBJ.Close(); sqlConnectionOBJ.Dispose(); } }
private void BindGrid() { using (SqlConnection constr = new SqlConnection()); { using (SqlCommand cmd = new SqlCommand("dbo.StoredProCustomer")) { cmd.Parameters.AddWithValue("@Action", "SELECT"); using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); GridViewCustomer.DataSource = dt; GridViewCustomer.DataBind(); } } } } }
private void BtnDelete_Click(object sender, EventArgs e) { int cid = Convert.ToInt32(GridViewCustomer.GetFocusedRowCellValue("CustomerId")); // 17 5 : สิทธิ์ใช้งานหน้าสมาชิก ลบข้อมูลสมาชิก int AuthorizeId = 17; if (SQLAuthorized.CheckAuthorized(ClassProperty.permisRoleId, AuthorizeId) == false) { SQLAuthorized.AlertAuthorized("สิทธิ์ใช้งานหน้าสมาชิก", "ไม่มีสิทธิ์ลบข้อมูลสมาชิก"); return; } if (CheckData(cid) == true) { if (XtraMessageBox.Show("คุณยืนยันที่จะลบข้อมูล ใช่หรือไม่?", "ยืนยัน", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { if (DeleteData(cid)) { LoadCustomer(); } } } }