protected void ImageButtonSearch_Click(object sender, ImageClickEventArgs e) { Supplier supplier = new Supplier(); supplier.S_name = TextBoxSearch.Text; double Debts; supplier = supplier.Get_Supplier_info(out Debts); if (string.IsNullOrEmpty(supplier.S_name)) { // display error panel PanelErrorMessage.Visible = true; // hide result panel PaenlSupplierInfo.Visible = false; } else { ViewState["S_Name"] = supplier.S_name; PaenlSupplierInfo.Visible = true; lblName.Text = supplier.S_name; lblAddress.Text = string.IsNullOrEmpty(supplier.Address) ? "لا يوجد" : supplier.Address; lblAccountNumber.Text = string.IsNullOrEmpty(supplier.Account_Number) ? "لا يوجد" : supplier.Account_Number; GridViewPhones.DataSource = Supplier_Phone.Get_Supplier_Phones(supplier.S_name); GridViewPhones.DataBind(); GridViewFaxs.DataSource = Supplier_Fax.Get_Supplier_Faxs(supplier.S_name); GridViewFaxs.DataBind(); Get_Records(supplier.S_name);//Bind supplier records grid PanelNotes.Visible = false; } }
protected void GridViewPhones_RowCommand(object sender, GridViewCommandEventArgs e) { lblContactsMsg.Text = ""; if (e.CommandName == "Edit_Row") { int row_index = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; ViewState["old_phone"] = ((Label)GridViewPhones.Rows[row_index].FindControl("lblPhone")).Text; GridViewPhones.EditIndex = row_index; BindPhones(ViewState["S_Name"].ToString()); } else if (e.CommandName == "Cancel_Update") { GridViewPhones.EditIndex = -1; BindPhones(ViewState["S_Name"].ToString()); } else if (e.CommandName == "Confirm_Update") { int row_index = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; Supplier_Phone phone = new Supplier_Phone(); phone.Phone = ((TextBox)GridViewPhones.Rows[row_index].FindControl("txtPhone")).Text; phone.S_name = ViewState["S_Name"].ToString(); string old_phone = ViewState["old_phone"].ToString(), m = ""; if (!phone.Update_Supplier_Phone(out m, old_phone)) { lblContactsMsg.Text = m; lblContactsMsg.ForeColor = System.Drawing.Color.Red; } else { lblContactsMsg.Text = "تم تحديث الهاتف بنجاح"; lblContactsMsg.ForeColor = System.Drawing.Color.Green; } GridViewPhones.EditIndex = -1; BindPhones(ViewState["S_Name"].ToString()); } else if (e.CommandName == "Delete_Row") { int row_index = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; Supplier_Phone phone = new Supplier_Phone(); phone.Phone = ((Label)GridViewPhones.Rows[row_index].FindControl("lblPhone")).Text; phone.S_name = ViewState["S_Name"].ToString(); string m = ""; if (!phone.Delete_Supplier_Phone(out m)) { lblContactsMsg.Text = m; lblContactsMsg.ForeColor = System.Drawing.Color.Red; } else { lblContactsMsg.Text = "تم مسح الهاتف "; lblContactsMsg.ForeColor = System.Drawing.Color.Green; } BindPhones(ViewState["S_Name"].ToString()); } }
protected void GridViewSuppliers_RowCommand(object sender, GridViewCommandEventArgs e) { // Select Supplier info int row_index = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; string supplier_name = GridViewSuppliers.Rows[row_index].Cells[0].Text; Supplier supplier = new Supplier(); supplier.S_name = supplier_name; double debts; supplier = supplier.Get_Supplier_info(out debts); lblSupplier.Text = supplier.S_name; lblAddress.Text = supplier.Address; lblAccountNumber.Text = supplier.Account_Number; GridViewPhones.DataSource = Supplier_Phone.Get_Supplier_Phones(supplier_name); GridViewPhones.DataBind(); GridViewFaxs.DataSource = Supplier_Fax.Get_Supplier_Faxs(supplier_name); GridViewFaxs.DataBind(); GridViewSuppliers.SelectedIndex = row_index; PanelSupplierInfo.Visible = true; SetFocus(GridViewFaxs); }
protected void BtnAdd_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtPhone.Text)) { Supplier_Phone sph = new Supplier_Phone(); sph.Phone = txtPhone.Text; sph.S_name = ViewState["Supplier_Name"] == null ? ViewState["S_Name"].ToString() : ViewState["Supplier_Name"].ToString(); string m = ""; if (!sph.Add_Supplier_Phones(out m)) { lblPhoneMsg.Text = m; lblPhoneMsg.ForeColor = System.Drawing.Color.Red; } else { lblPhoneMsg.Text = "تم بنجاح"; lblPhoneMsg.ForeColor = System.Drawing.Color.Green; } } if (!string.IsNullOrEmpty(txtFax.Text)) { Supplier_Fax sfx = new Supplier_Fax(); sfx.Fax = txtFax.Text; sfx.S_name = ViewState["Supplier_Name"] == null ? ViewState["S_Name"].ToString() : ViewState["Supplier_Name"].ToString(); string m = ""; if (!sfx.Add_Supplier_Faxs(out m)) { lblFaxMsg.Text = m; lblFaxMsg.ForeColor = System.Drawing.Color.Red; } else { lblFaxMsg.Text = "تم بنجاح"; lblFaxMsg.ForeColor = System.Drawing.Color.Green; } } }
private void BindPhones(string supplier) { GridViewPhones.DataSource = Supplier_Phone.Get_Supplier_Phones(supplier); GridViewPhones.DataBind(); }