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 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 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(); } }