public void RefreshOut(string statment) { DataSet data = new DataSet(); db.selectDB(ref data, statment); outcome_gridview.DataSource = data.Tables[0]; }
public void RefreshTheBill() { try { data = new DataSet(); DataSet data2 = new DataSet(); new Thread(() => { if (InvokeRequired) { this.Invoke(new MethodInvoker(delegate { db.selectDB(ref data, "SELECT * FROM bill where id='" + Id + "'"); db.selectDB(ref data2, "SELECT cust_name,cust_type from customer where cust_id='" + data.Tables[0].Rows[0][2] + "'"); DataSet dataUser = new DataSet(); db.selectDB(ref dataUser, "SELECT user_fullname from users WHERE user_id='" + data.Tables[0].Rows[0][11] + "'"); name_label.Text = "اسم ال" + data2.Tables[0].Rows[0][1]; pk_label.Text = Id + ""; id_label.Text = data.Tables[0].Rows[0][1].ToString(); cust_label.Text = data2.Tables[0].Rows[0][0].ToString(); rec_label.Text = FormatDate(Convert.ToDateTime(data.Tables[0].Rows[0][7])); teeth_label.Text = concate(db.ListOF("SELECT number from teeth where bill_id=" + Id)); type_label.Text = data.Tables[0].Rows[0][5].ToString(); string delv_state = data.Tables[0].Rows[0][6].ToString(); delv_state_label.Text = delv_state; if (delv_state != "لم يسلم") { delv_label.Text = FormatDate(Convert.ToDateTime(data.Tables[0].Rows[0][8].ToString())); delv_show_label.Visible = true; delv_label.Visible = true; } else { delv_show_label.Visible = false; delv_label.Visible = false; } color_label.Text = data.Tables[0].Rows[0][4].ToString(); price_label.Text = data.Tables[0].Rows[0][9].ToString(); notes_label.Text = data.Tables[0].Rows[0][10].ToString(); user_label.Text = dataUser.Tables[0].Rows[0][0].ToString(); user_role = db.SelectStr("SELECT user_role from users WHERE user_id=" + user_id); DateTime rec = Convert.ToDateTime(data.Tables[0].Rows[0][7]); this.rec = rec; today_label.Text = FormatDate(DateTime.Today); })); } }).Start(); } catch { this.Close(); } }
private void RefreshPay() { String query = "SELECT c.cust_name,p.pay_price,p.pay_date,p.pay_note FROM payments p, customer c WHERE pay_id='" + id + "' AND c.cust_id=p.cust_id"; DataSet data = new DataSet(); db.selectDB(ref data, query); label_id.Text = id + ""; label_cust.Text = data.Tables[0].Rows[0][0].ToString(); label_price.Text = data.Tables[0].Rows[0][1].ToString(); label_date.Text = data.Tables[0].Rows[0][2].ToString(); label_note.Text = data.Tables[0].Rows[0][3].ToString(); }
private void AddCustomerForm_Load(object sender, EventArgs e) { if (cases == 2) { DataSet data = new DataSet(); db.selectDB(ref data, "SELECT * FROM customer WHERE cust_id=" + id); LinkedList <string> phones = db.ListOF("Select number from phones where cust_id=" + id); name_txt.Text = data.Tables[0].Rows[0][1].ToString(); string type = data.Tables[0].Rows[0][2].ToString(); if (type == "دكتور") { type_combo.SelectedIndex = 0; } else if (type == "مختبر") { type_combo.SelectedIndex = 1; } else { type_combo.SelectedIndex = 2; } email_txt.Text = data.Tables[0].Rows[0][3].ToString(); phone_list.Clear(); foreach (string s in phones) { phone_list.Items.Add(s); } } }
private void RefreshWarr() { try { DataSet data = new DataSet(); db.selectDB(ref data, "SELECT * FROM warrnity WHERE bill_id='" + id + "'"); if (data.Tables[0].Rows.Count > 0) { DataSet data2 = new DataSet(); db.selectDB(ref data2, "SELECT c.cust_name,c.cust_type from customer c,bill b WHERE b.cust_id=c.cust_id and b.id=" + id); patient = data.Tables[0].Rows[0][0].ToString(); patient_label.Text = patient; customer_show_label.Text = "اسم ال" + data2.Tables[0].Rows[0][1]; customer_label.Text = data2.Tables[0].Rows[0][0].ToString(); bill_label.Text = db.SelectStr("SELECT bill_id FROM bill WHERE id='" + id + "'"); delv_label.Text = FormatDate(db.SelectDate("SELECT bill_delv_date from bill WHERE bill_id=" + id)); period = Convert.ToInt32(data.Tables[0].Rows[0][1].ToString()); if (period == 1) { warr_period_label.Text = " سنه"; } else if (period == 2) { warr_period_label.Text = " سنتين"; } else { warr_period_label.Text = period + " سنوات"; } } else { this.Close(); MessageBox.Show("لا توجد كفاله"); } } catch { this.Close(); } }
public void RefreshCheck() { try { string select_query = "SELECT ch_id as 'رقم الشك',ch_bank as 'اسم البنك',ch_owner as 'صاحب الشك',ch_date 'تاريخ صرف الشك',ch_price as 'قيمه الشك',ch_notes 'ملاحظات' from checks where bill_id='" + Id + "'"; DataSet data = new DataSet(); db.selectDB(ref data, select_query); check_gridview.DataSource = data.Tables[0]; } catch { this.Close(); } }
public AddSellerForm(MainForm form, int id) { InitializeComponent(); this.form = form; db = new SqlConnectionDB(); this.id = id; casses = 2; this.Text = "تعديل التاجر"; button1.Text = "تعديل"; DataSet data = new DataSet(); db.selectDB(ref data, "SELECT * FROM seller WHERE sell_id=" + id); name_txt.Text = data.Tables[0].Rows[0][1].ToString(); phone_txt.Text = data.Tables[0].Rows[0][2].ToString(); email_txt.Text = data.Tables[0].Rows[0][3].ToString(); }
public void RefreshData() { try { String teethe_query = "SELECT COALESCE(GROUP_CONCAT(t.number SEPARATOR ','),'مثبت') " + "FROM teeth t WHERE t.bill_id=bill.id"; String bill_query = "SELECT id as 'الرقم التسلسلي',bill_id as 'رقم الفاتوره' " + ", bill_teethes as 'عدد الاسنان' , (" + teethe_query + ") as 'الاسنان' " + ", bill_price as 'السعر' , bill_rec_date as 'تاريخ الاستلام'" + ", bill_delv_state as 'حاله التسليم' from bill WHERE cust_id='" + Id + "'" + " AND bill_rec_date BETWEEN '" + FormatDate(datefrom_pic.Value) + "'" + " AND '" + FormatDate(dateto_pic.Value) + "' ORDER BY id DESC"; String payment_query = "SELECT pay_id as 'الرقم التسلسلي' , pay_price as 'قيمه الكاش' " + ", (SELECT COALESCE(SUM(ch_price), 0) " + "FROM checks WHERE bill_id=payments.pay_id) as 'قيمه الشكات' " + ", pay_date as 'تاريخ الدفعه' FROM payments WHERE cust_id='" + Id + "'" + " AND pay_date BETWEEN '" + FormatDate(datefrom_pic.Value) + "'" + " AND '" + FormatDate(dateto_pic.Value) + "' ORDER BY pay_id DESC"; String debit_query = "SELECT deb_id as 'الرقم التسلسلي' , deb_date as 'تاريخ الدين' " + ", deb_price as 'قيمه الدين' FROM debits WHERE cust_id='" + Id + "'" + " AND deb_date BETWEEN '" + FormatDate(datefrom_pic.Value) + "'" + " AND '" + FormatDate(dateto_pic.Value) + "' ORDER BY deb_id DESC"; String discount_query = "SELECT dis_id as 'الرقم التسلسلي' , dis_total as 'البلغ الكامل'" + ", dis_ratio 'نسبه الخصم' , dis_price as 'المبلغ بعد الخصم' " + ", dis_date as 'تاريخ الخصم' FROM discounts WHERE cust_id='" + Id + "'" + " AND dis_date BETWEEN '" + FormatDate(datefrom_pic.Value) + "'" + " AND '" + FormatDate(dateto_pic.Value) + "' ORDER BY dis_id DESC"; //MessageBox.Show(bill_query); DataSet bill_data = new DataSet(); DataSet payment_data = new DataSet(); DataSet debit_data = new DataSet(); DataSet discount_data = new DataSet(); db.selectDB(ref bill_data, bill_query); db.selectDB(ref payment_data, payment_query); db.selectDB(ref debit_data, debit_query); db.selectDB(ref discount_data, discount_query); bill_girdview.DataSource = bill_data.Tables[0]; payment_gridview.DataSource = payment_data.Tables[0]; debits_gridview.DataSource = debit_data.Tables[0]; discount_gridview.DataSource = discount_data.Tables[0]; DateTime today = DateTime.Today; date_label.Text = FormatDate(today); cust_label.Text = db.SelectStr("SELECT cust_name from customer where cust_id=" + Id); double bill_sum = 0; double payment_sum = 0; double debits_sum = 0; double discountsum = 0; for (int i = 0; i < bill_girdview.RowCount; i++) { if (bill_girdview.Rows[i].Cells[6].Value.ToString() == "تم التسليم") { bill_sum += Convert.ToDouble(bill_girdview.Rows[i].Cells[4].Value.ToString()); } } for (int i = 0; i < payment_gridview.RowCount; i++) { double price = Convert.ToDouble(payment_gridview.Rows[i].Cells[1].Value.ToString()); double check = Convert.ToDouble(payment_gridview.Rows[i].Cells[2].Value.ToString()); payment_sum += price + check; } for (int i = 0; i < debits_gridview.RowCount; i++) { debits_sum += Convert.ToDouble(debits_gridview.Rows[i].Cells[2].Value.ToString()); } for (int i = 0; i < discount_gridview.RowCount; i++) { discountsum += Convert.ToDouble(discount_gridview.Rows[i].Cells[3].Value.ToString()); } total.Text = bill_sum + ""; total_paid_label.Text = payment_sum + ""; debt_label.Text = debits_sum + ""; sale_label.Text = discountsum + ""; final_amount = bill_sum + debits_sum - payment_sum - discountsum; final_total_label.Text = final_amount + ""; } catch { this.Close(); } }