private void button3_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; dataGridView2.DataSource = null; string month = cmbonlymonth.Text; string year = cmbyearonlymonth.Text; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select Name,Number from Factor where Month='" + month + "' and Year='" + year + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); string selectCmd2 = string.Format("Select Name,Number from Sefaresh where MajlesMonth='" + month + "' and MajlesYear='" + year + "'"); string hasrows2 = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { search("Select Name,SUM(Number) as aa from Factor where Month='" + month + "' and Year='" + year + "' group by Name"); } if (hasrows2 == "ok") { search2("Select Name,SUM(Number) as aa from Sefaresh where MajlesMonth='" + month + "' and MajlesYear='" + year + "' group by Name"); } if (hasrows != "ok" && hasrows2 != "ok") { MessageBox.Show("در این ماه غذایی ثبت نشده است"); } } catch { MessageBox.Show("جستجو امکان پذیر نیست"); } }
private void button2_Click(object sender, EventArgs e) { try { dataGridView1.DataSource = null; textBox1.Text = "0"; txtProtakhfif.TextValue = 0; txtProtakhfiffactor.TextValue = 0; txtProforoshfactor.TextValue = 0; txtProforoshsefaresh.TextValue = 0; txtProsoodfactor.TextValue = 0; txtProsoodsefaresh.TextValue = 0; clearform(); DBManagment objDBClass = new DBManagment(); string MajlesDate = cmbyear.Text + "/" + cmbmonth.Text + "/" + cmbday.Text; string selectCmd = string.Format("Select * from Sefaresh where SabtDate='" + MajlesDate + "'"); string selectCmd2 = string.Format("Select * from Factor where Date='" + MajlesDate + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); string hastrows2 = objDBClass.SelectHasRows(selectCmd2); int halat = 1; if (hasrows == "ok") { takhfifsefaresh("select SUM(Takhfif)as takhfif from ( Select DISTINCT Sefareshid, Takhfif from Sefaresh where SabtDate='" + MajlesDate + "' ) as newtable "); sumpricesefaresh(" Select SUM(SumPrice)as SUM,SUM(Sood) as sood from Sefaresh where SabtDate='" + MajlesDate + "' "); summoney(" Select SUM(Money)as SUM from SefareshMoney where MoneyDate='" + MajlesDate + "' "); bedehkarlist(" Select Sefareshid,Des from Sefaresh where SabtDate='" + MajlesDate + "' and halat= '" + halat + "' "); } if (hastrows2 == "ok") { takhfiffactor("select SUM(Takhfif)as takhfif from ( Select DISTINCT Factorid, Takhfif from Factor where Date='" + MajlesDate + "' ) as newtable "); sumpricefactor(" Select SUM(SumPrice)as SUM,SUM(Sood) as sood from Factor where Date='" + MajlesDate + "' "); } if (hasrows != "ok" && hastrows2 != "ok") { MessageBox.Show("در این تاریخ فاکتور و سفارشی ثبت نشد"); } txtProkoltakhfif.Text = (Int64.Parse(txtProtakhfif.TextValue.ToString()) + Int64.Parse(txtProtakhfiffactor.TextValue.ToString())).ToString(); txtProkolforosh.Text = (Int64.Parse(txtProforoshfactor.TextValue.ToString()) + Int64.Parse(txtProforoshsefaresh.TextValue.ToString())).ToString(); txtProkolsood.Text = (Int64.Parse(txtProsoodfactor.TextValue.ToString()) + Int64.Parse(txtProsoodsefaresh.TextValue.ToString())).ToString(); } catch { MessageBox.Show("امکان انجام عملیات مقدور نمی باشد", "توجه"); } }
private void button5_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("select * from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "' "); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { search("select Sefareshid,MoneyDate,Money from SefareshMoney where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "' "); sumprice(" Select SUM(SumPrice)as SUM from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "' "); takhfif(" Select Takhfif from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "' "); bedehkar(); } else { MessageBox.Show("سفارشی با این شماره یافت نشده است"); } } catch { MessageBox.Show("جستجو امکان پذیر نمی باشد"); } }
private void اطلاعات_کامل_سفارش_Load(object sender, EventArgs e) { try { string ids = f1.textBox1.Text; Int64 id = Int64.Parse(ids); DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select * from Sefaresh where Sefareshid='" + id + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { //clearform(); search("Select Name,Number,Price,SumPrice from Sefaresh where Sefareshid='" + id + "'"); search2("Select Money,MoneyDate from SefareshMoney where Sefareshid='" + id + "'"); select("Select * from Sefaresh where Sefareshid='" + id + "'"); sumprice("Select SUM(SumPrice)as SUM,SUM(Sood) as sood from Sefaresh where Sefareshid='" + id + "' "); bedehkar(); } else { MessageBox.Show("سفارشی با این شماره یافت نشده است"); } } catch { MessageBox.Show("امکان انجام عملیات مقدور نمی باشد", "توجه"); } }
private void button1_Click(object sender, EventArgs e) { try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select Name,Number,Price,SumPrice from Factor where Factorid='" + Int64.Parse(textBox1.Text) + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { search("Select Name,Number,Price,SumPrice from Factor where Factorid='" + Int64.Parse(textBox1.Text) + "'"); sumprice("Select SUM(SumPrice)as SUM,SUM(Sood)as sood from Factor where Factorid='" + Int64.Parse(textBox1.Text) + "' "); } else { MessageBox.Show("این شماره فاکتور وجود ندارد"); } } catch { MessageBox.Show("جستجو امکان پذیر نیست"); } }
private void button2_Click(object sender, EventArgs e) { string year = cmbyear.Text; string month = cmbmonth.Text; string day = cmbday.Text; string date = year + "/" + month + "/" + day; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select Name,Number,Price,SumPrice from Factor where Date='" + date + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { search("Select Name,Number,Price,SumPrice from Factor where Date='" + date + "'"); sumprice("Select SUM(SumPrice)as SUM,SUM(Sood)as Sood from Factor where Date='" + date + "' "); } else { MessageBox.Show("در این تاریخ فاکتوری ثبت نشده است"); } } catch { MessageBox.Show("جستجو امکان پذیر نیست"); } }
private void button2_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; string year = cmbyear.Text; string month = cmbmonth.Text; string day = cmbday.Text; string date = year + "/" + month + "/" + day; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select Factorid from Factor where Date='" + date + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { search("Select Factorid from Factor where Date='" + date + "'"); } else { MessageBox.Show("در این تاریخ فاکتوری ثبت نشده است"); } } catch { MessageBox.Show("جستجو امکان پذیر نیست"); } }
private void button4_Click(object sender, EventArgs e) { string year = cmbonlyyears.Text; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select Name,Number,Price,SumPrice from Factor where Year='" + year + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { search("Select Name,Number,Price,SumPrice from Factor where Year='" + year + "'"); sumprice("Select SUM(SumPrice)as SUM,SUM(Sood)as Sood from Factor where Year='" + year + "' "); } else { MessageBox.Show("در این سال فاکتوری ثبت نشده است"); } } catch { MessageBox.Show("جستجو امکان پذیر نیست"); } }
private void button2_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; dataGridView2.DataSource = null; string year = cmbyear.Text; string month = cmbmonth.Text; string day = cmbday.Text; string date = year + "/" + month + "/" + day; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select Name,Number from Factor where Date='" + date + "' "); string hasrows = objDBClass.SelectHasRows(selectCmd); string selectCmd2 = string.Format("Select Name,Number from Sefaresh where MajlesDate='" + date + "' "); string hasrows2 = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok" && hasrows2 == "ok") { search("Select Name,SUM(Number) as aa from Factor where Date='" + date + "' group by Name"); search2("Select Name,SUM(Number) as aa from Sefaresh where MajlesDate='" + date + "' group by Name"); // sumprice("Select SUM(SumPrice)as SUM,SUM(Sood)as Sood from Factor where Date='" + date + "' "); } else { if (hasrows == "ok") { search("Select Name,SUM(Number) as aa from Factor where Date='" + date + "' group by Name"); } if (hasrows2 == "ok") { search2("Select Name,SUM(Number) as aa from Sefaresh where MajlesDate='" + date + "' group by Name"); } if (hasrows != "ok" && hasrows2 != "ok") { MessageBox.Show("در این تاریخ غذایی ثبت نشده است"); } } } catch { MessageBox.Show("جستجو امکان پذیر نیست"); } }
private void تغییر_اطلاعات_فاکتورها_Load(object sender, EventArgs e) { txtfactorid.Text = f1.textBox1.Text; // tring name = dataGridView2.CurrentRow.Cells[1].Value.ToString(); SqlConnection objcon1 = new SqlConnection("Data Source=Localhost;Initial Catalog=FoodDB; Integrated Security=True"); SqlDataAdapter objadapter1 = new SqlDataAdapter("Select takhfif from Factor where Factorid='" + Int64.Parse(txtfactorid.Text) + "'", objcon1); DataSet objset1 = new DataSet(); objadapter1.Fill(objset1, "Factor"); DataRow objdatarow1 = objset1.Tables["Factor"].Rows[0]; string takhfif = objdatarow1["takhfif"].ToString(); SqlConnection objcon2 = new SqlConnection("Data Source=Localhost;Initial Catalog=FoodDB; Integrated Security=True"); SqlDataAdapter objadapter2 = new SqlDataAdapter("Select SUM(SumPrice) as sum from Factor where Factorid='" + Int64.Parse(txtfactorid.Text) + "'", objcon2); DataSet objset2 = new DataSet(); objadapter2.Fill(objset2, "Factor"); DataRow objdatarow2 = objset2.Tables["Factor"].Rows[0]; string sum = objdatarow2["sum"].ToString(); txtProNet1.Text = sum; if (takhfif == "") { txtProtakhfif.Visible = false; label7.Visible = true; txtProNet2.Text = txtProNet1.Text; } else { txtProtakhfif.Text = takhfif; label7.Visible = false; txtProNet2.Text = (Int64.Parse(txtProNet1.TextValue.ToString()) - Int64.Parse(txtProtakhfif.TextValue.ToString())).ToString(); } DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select Name,Number,Price,SumPrice from Factor where Factorid='" + Int64.Parse(txtfactorid.Text) + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { loadgridview2(); loadgridview1(); } else { MessageBox.Show("فاکتوری با این شماره یافت نشده است"); } string status = "0"; DBManagment objclass = new DBManagment(); objclass.Deleterowtable("Delete Sefaresh where status='" + int.Parse(status) + "' "); }
private void button6_Click_1(object sender, System.EventArgs e) { try { // tring name = dataGridView2.CurrentRow.Cells[1].Value.ToString(); SqlConnection objcon1 = new SqlConnection("Data Source=Localhost;Initial Catalog=FoodDB; Integrated Security=True"); SqlDataAdapter objadapter1 = new SqlDataAdapter("Select takhfif from Factor where Factorid='" + Int64.Parse(txtfactorid.Text) + "'", objcon1); DataSet objset1 = new DataSet(); objadapter1.Fill(objset1, "Factor"); DataRow objdatarow1 = objset1.Tables["Factor"].Rows[0]; string takhfif = objdatarow1["takhfif"].ToString(); SqlConnection objcon2 = new SqlConnection("Data Source=Localhost;Initial Catalog=FoodDB; Integrated Security=True"); SqlDataAdapter objadapter2 = new SqlDataAdapter("Select SUM(SumPrice) as sum from Factor where Factorid='" + Int64.Parse(txtfactorid.Text) + "'", objcon2); DataSet objset2 = new DataSet(); objadapter2.Fill(objset2, "Factor"); DataRow objdatarow2 = objset2.Tables["Factor"].Rows[0]; string sum = objdatarow2["sum"].ToString(); txtProNet1.Text = sum; if (takhfif == "") { txtProtakhfif.Visible = false; label7.Visible = true; txtProNet2.Text = txtProNet1.Text; } else { txtProtakhfif.Text = takhfif; label7.Visible = false; txtProNet2.Text = (Int64.Parse(txtProNet1.TextValue.ToString()) - Int64.Parse(txtProtakhfif.TextValue.ToString())).ToString(); } DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select Name,Number,Price,SumPrice from Factor where Factorid='" + Int64.Parse(txtfactorid.Text) + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { loadgridview2(); loadgridview1(); } else { MessageBox.Show("فاکتوری با این شماره یافت نشده است"); } } catch { MessageBox.Show("امکان انجام عملیات مقدور نمی باشد", "توجه"); } }
private void تغییر_سفارش2_Load(object sender, EventArgs e) { txtsefareshid0.Text = f1.textBox1.Text; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select * from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { SqlConnection objcon1 = new SqlConnection("Data Source=Localhost;Initial Catalog=FoodDB; Integrated Security=True"); SqlDataAdapter objadapter1 = new SqlDataAdapter("Select halat from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'", objcon1); DataSet objset1 = new DataSet(); objadapter1.Fill(objset1, "Sefaresh"); DataRow objdatarow1 = objset1.Tables["Sefaresh"].Rows[0]; string halat = objdatarow1["halat"].ToString(); int halate = int.Parse(halat); if (halate == 1) { clearform(); search("Select id,Name,Number,Price,SumPrice,OneSood from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); select("Select * from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); sumprice(" Select SUM(SumPrice)as SUM,SUM(Sood) as sood from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "' "); } else { MessageBox.Show("این سفارش بایگانی شده و قابل تغییر نیست"); } } else { MessageBox.Show("سفارشی با این شماره یافت نشده است"); } } catch { } Loadgridview(); string status = "0"; DBManagment objclass = new DBManagment(); objclass.Deleterowtable("Delete Sefaresh where status='" + int.Parse(status) + "' "); }
private void button1_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; dataGridView2.DataSource = null; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select * from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { //clearform(); search("Select Name,Number,Price,SumPrice from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); DBManagment objDBClass1 = new DBManagment(); string selectCmd1 = string.Format("Select * from SefareshMoney where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); string hasrows1 = objDBClass.SelectHasRows(selectCmd); if (hasrows1 == "ok") { search2("Select MoneyDate,Money from SefareshMoney where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); } select("Select * from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); selectfinishdate("Select * from SefareshMoney where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'"); sumprice("Select SUM(SumPrice)as SUM,SUM(Sood) as sood from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "' "); bedehkar(); } else { MessageBox.Show("سفارشی با این شماره یافت نشده است"); } } catch { MessageBox.Show("جستجو امکان پذیر نیست"); } }
public void bedehkarlist(string select) { DBManagment objdbclass = new DBManagment(); string hastows = objdbclass.SelectHasRows(select); if (hastows == "ok") { SqlConnection objcon1 = new SqlConnection("Data Source=Localhost;Initial Catalog=FoodDB; Integrated Security=True"); SqlDataAdapter objadapter1 = new SqlDataAdapter(select, objcon1); DataSet objset1 = new DataSet(); objadapter1.Fill(objset1, "Sefaresh"); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = objset1; dataGridView1.DataMember = "Sefaresh"; dataGridView1.Columns[0].HeaderText = " شماره سفارش"; dataGridView1.Columns[1].HeaderText = "نام سفارش دهنده"; } }
private void button4_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; try { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("select DisTINCT Sefareshid,Des,SabtDate,MajlesDate from Sefaresh where MajlesYear='" + cmbonlyyears.Text + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { select("select DisTINCT Sefareshid,Des,SabtDate,MajlesDate from Sefaresh where MajlesYear='" + cmbonlyyears.Text + "'"); } else { MessageBox.Show("در این تاریخ مجلسی ثبت نشده است"); } } catch { MessageBox.Show("جستجو امکان پذیر نمی باشد"); } }
private void button1_Click_1(object sender, EventArgs e) { DBManagment objDBClass = new DBManagment(); string selectCmd = string.Format("Select * from Factor where Factorid='" + Int64.Parse(txtfactorid.Text) + "' and Name=N'" + lblname.Text + "'"); string hasrows = objDBClass.SelectHasRows(selectCmd); if (hasrows == "ok") { MessageBox.Show("این غذا را ثبت کرده اید لطفا از جدول پایینی تعداد آنرا اضافه کنید", "توجه"); } else { bool successfullCreateAccount = true; try { Int64 sood = Int64.Parse(lblprice.Text) - Int64.Parse(lblhazine.Text); string DateDay = FarsiLibrary.Utils.PersianDate.Now.ToString().Substring(0, 10); string Year = FarsiLibrary.Utils.PersianDate.Now.Year.ToString(); string Month = FarsiLibrary.Utils.PersianDate.Now.Month.ToString(); string Day = FarsiLibrary.Utils.PersianDate.Now.Day.ToString(); DBManagment objdbclass = new DBManagment(); string adi = "1"; objdbclass.Inserttable("Insert Into Factor (Factorid,Name,Number,Price,SumPrice,Sood,Date,Year,Month,Day,Type,Takhfif,status) Values (N'" + Int64.Parse(txtfactorid.Text) + "', N'" + lblname.Text + "' ,'" + Int64.Parse(lbltedad.Text) + "','" + Int64.Parse(lblprice.Text) + "','" + Int64.Parse(lblprice.Text) * Int64.Parse(lbltedad.Text) + "','" + sood * Int64.Parse(lbltedad.Text) + "','" + DateDay + "','" + Year + "','" + Month + "','" + Day + "','" + adi + "','" + Int64.Parse("0") + "','" + Int64.Parse("0") + "')"); loadgridview2(); Int64 sum = Int64.Parse(lblprice.Text) * Int32.Parse(lbltedad.Text); txtProNet1.Text = (Int64.Parse(txtProNet1.TextValue.ToString()) + sum).ToString(); string takhfif = txtProtakhfif.TextValue.ToString(); txtProNet2.Text = (Int64.Parse(txtProNet1.TextValue.ToString()) - Int64.Parse(takhfif)).ToString(); } catch { successfullCreateAccount = false; MessageBox.Show("ثبت غذا امکانپذیر نمی باشد", "توجه"); } } }
public void summoney(string where) { DBManagment objdbclass = new DBManagment(); string hastows = objdbclass.SelectHasRows(where); if (hastows == "ok") { SqlConnection objcon1 = new SqlConnection("Data Source=Localhost;Initial Catalog=FoodDB; Integrated Security=True"); SqlDataAdapter objadapter1 = new SqlDataAdapter(where, objcon1); DataSet objset1 = new DataSet(); objadapter1.Fill(objset1, "SefareshMoney"); DataRow objdatarow1 = objset1.Tables["SefareshMoney"].Rows[0]; textBox1.Text = objdatarow1["SUM"].ToString(); } else { } Int64 mablaghvarizisefaresh = Int64.Parse(textBox1.Text); Int64 forosh = Int64.Parse(txtProforoshfactor.TextValue.ToString()); Int64 varizi = forosh + mablaghvarizisefaresh; txtProsandogh.Text = (varizi).ToString(); }