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 GridViewFaxs_RowCommand(object sender, GridViewCommandEventArgs e) { lblContactsMsg.Text = ""; if (e.CommandName == "Edit_Row") { int row_index = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; ViewState["old_fax"] = ((Label)GridViewFaxs.Rows[row_index].FindControl("lblFax")).Text; GridViewFaxs.EditIndex = row_index; BindFaxs(ViewState["S_Name"].ToString()); } else if (e.CommandName == "Cancel_Update") { GridViewFaxs.EditIndex = -1; BindFaxs(ViewState["S_Name"].ToString()); } else if (e.CommandName == "Confirm_Update") { int row_index = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; Supplier_Fax fax = new Supplier_Fax(); fax.Fax = ((TextBox)GridViewFaxs.Rows[row_index].FindControl("txtFax")).Text; fax.S_name = ViewState["S_Name"].ToString(); string old_Fax = ViewState["old_fax"].ToString(), m = ""; if (!fax.Update_Supplier_Fax(out m, old_Fax)) { lblContactsMsg.Text = m; lblContactsMsg.ForeColor = System.Drawing.Color.Red; } else { lblContactsMsg.Text = "تم تحديث الفاكس بنجاح"; lblContactsMsg.ForeColor = System.Drawing.Color.Green; } GridViewFaxs.EditIndex = -1; BindFaxs(ViewState["S_Name"].ToString()); } else if (e.CommandName == "Delete_Row") { int row_index = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; Supplier_Fax fax = new Supplier_Fax(); fax.Fax = ((Label)GridViewFaxs.Rows[row_index].FindControl("lblFax")).Text; fax.S_name = ViewState["S_Name"].ToString(); string m = ""; if (!fax.Delete_Supplier_Fax(out m)) { lblContactsMsg.Text = m; lblContactsMsg.ForeColor = System.Drawing.Color.Red; } else { lblContactsMsg.Text = "تم مسح الفاكس "; lblContactsMsg.ForeColor = System.Drawing.Color.Green; } BindFaxs(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 BindFaxs(string supplier) { GridViewFaxs.DataSource = Supplier_Fax.Get_Supplier_Faxs(supplier); GridViewFaxs.DataBind(); }