private void Btn_Save_Click(object sender, EventArgs e) { if (AddNew == false) { MessageBox.Show("يجب الضغط على زر جديد اولا", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if ((MessageBox.Show("هل انت متأكد من حفظ عمليةالشراء ؟", "تأكيد", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { DataTable ddt = PrepareData(); ccon.Comm.Connection = DBConnect.Conn; ccon.Comm.CommandType = CommandType.StoredProcedure; ccon.Comm.CommandText = "Sp_SalesInsert"; ccon.Comm.Parameters.Clear(); ccon.Comm.Parameters.AddWithValue("@Cust_ID", int.Parse(Cmb_CustName.SelectedValue.ToString())); ccon.Comm.Parameters.AddWithValue("@Sales_Date", DateTime.Parse(DTP_Purchase.Text)); ccon.Comm.Parameters.AddWithValue("@Total_Value", double.Parse(Txt_Total.Text)); ccon.Comm.Parameters.AddWithValue("@Payed_Value", double.Parse(Txt_Payed.Text)); ccon.Comm.Parameters.AddWithValue("@Remain_Value", double.Parse(Txt_Remain.Text)); ccon.Comm.Parameters.AddWithValue("@Sales_Notes", Txt_Notes.Text); ccon.Comm.Parameters.AddWithValue("@User_ID", Login.UserID); ccon.Comm.Parameters.AddWithValue("@Store_ID", int.Parse(Cmb_StoreName.SelectedValue.ToString())); ccon.Comm.Parameters.AddWithValue("@SalesDataTable", PrepareData()); ccon.Comm.ExecuteNonQuery(); MessageBox.Show("تم الحفظ بنجاح", "تم", MessageBoxButtons.OK, MessageBoxIcon.Information); AddNew = false; if ((MessageBox.Show("هل تريد طباعة عمليةالشراء ؟", "تأكيد", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { DBConnect Connn = new DBConnect(); Connn.Comm.Connection = DBConnect.Conn; Connn.Comm.CommandType = CommandType.StoredProcedure; Connn.Comm.CommandText = "Sp_MainSalesSelectMax"; SqlDataAdapter Da = new SqlDataAdapter(Connn.Comm); DataSet Ds = new DataSet(); Da.Fill(Ds, "BillSales"); BillReport_Sales Rpt = new BillReport_Sales(); Rpt.SetDataSource(Ds.Tables["BillSales"]); Frm_Report Frm = new Frm_Report(); Frm.crystalReportViewer1.ReportSource = Rpt; Frm.ShowDialog(); } } }
private void Btn_Report_Click(object sender, EventArgs e) { DBConnect Connn = new DBConnect(); Connn.Comm.Connection = DBConnect.Conn; Connn.Comm.CommandType = CommandType.StoredProcedure; Connn.Comm.CommandText = "Sp_MainSalesSelectMax"; SqlDataAdapter Da = new SqlDataAdapter(Connn.Comm); DataSet Ds = new DataSet(); Da.Fill(Ds, "BillSales"); BillReport_Sales Rpt = new BillReport_Sales(); Rpt.SetDataSource(Ds.Tables["BillSales"]); Frm_Report Frm = new Frm_Report(); Frm.crystalReportViewer1.ReportSource = Rpt; Frm.ShowDialog(); }