Ejemplo n.º 1
0
        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("جستجو امکان پذیر نمی باشد");
            }
        }
Ejemplo n.º 2
0
        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 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)
        {
            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 تغییر_فاکتور_Load(object sender, System.EventArgs e)
        {
            string      status   = "0";
            DBManagment objclass = new DBManagment();

            objclass.Deleterowtable("Delete Factor where  status='" + int.Parse(status) + "' ");
        }
        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 تغییر_سفارش_Load(object sender, EventArgs e)
        {
            Loadgridview();
            string      status   = "0";
            DBManagment objclass = new DBManagment();

            objclass.Deleterowtable("Delete Sefaresh where  status='" + int.Parse(status) + "' ");
        }
        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 button8_Click(object sender, EventArgs e)
        {
            try
            {
                string         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 hazine from Foods where Name=N'" + name + "'", objcon1);
                DataSet        objset1     = new DataSet();
                objadapter1.Fill(objset1, "Foods");
                DataRow objdatarow1 = objset1.Tables["Foods"].Rows[0];

                string hazine  = objdatarow1["hazine"].ToString();
                Int64  hazinee = Int64.Parse(hazine);

                string tedad  = dataGridView2.CurrentRow.Cells[2].Value.ToString();
                string price  = dataGridView2.CurrentRow.Cells[3].Value.ToString();
                Int64  pricee = Int64.Parse(price);


                int tedade = int.Parse(tedad) - 1;
                if (tedade > 0)
                {
                    Int64       sood       = pricee - hazinee;
                    DBManagment objdbclass = new DBManagment();

                    objdbclass.Updatetable("Update Factor Set Number='" + tedade + "',SumPrice='" + tedade * pricee + "',Sood='" + sood * tedade + "'   where Name=N'" + name + "' and Factorid='" + Int64.Parse(txtfactorid.Text) + "'   ");
                    loadgridview2();
                    Int64 sum = pricee * tedade;
                    //txtProNet1.Text = sum.ToString();
                    //string takhfif = txtProtakhfif.TextValue.ToString();
                    //txtProNet2.Text = (Int64.Parse(txtProNet1.TextValue.ToString()) - Int64.Parse(takhfif)).ToString();
                    DBManagment   objDBClass = new DBManagment();
                    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];


                    txtProNet1.Text = objdatarow2["sum"].ToString();
                    string takhfif = txtProtakhfif.TextValue.ToString();
                    txtProNet2.Text = (Int64.Parse(txtProNet1.TextValue.ToString()) - Int64.Parse(takhfif)).ToString();
                }

                else
                {
                    MessageBox.Show("امکان کم کردن تعداد این غذا وجود ندارد", "توجه");
                }
            }
            catch
            {
                MessageBox.Show("امکان انجام عملیات مقدور نمی باشد", "توجه");
            }
        }
        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 ثبت_سفارش_Load(object sender, EventArgs e)
        {
            string      status   = "0";
            DBManagment objclass = new DBManagment();

            objclass.Deleterowtable("Delete Sefaresh where  status='" + int.Parse(status) + "' ");
            string DateDay = FarsiLibrary.Utils.PersianDate.Now.ToString().Substring(0, 10);

            lbfactorid.Text = DateDay.Replace("/", "") + "" + DateTime.Now.Hour.ToString() + "" + DateTime.Now.Minute.ToString() + "" + DateTime.Now.Second.ToString();
            label8.Text     = DateDay + "  " + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();
            Loadgridview();
        }
        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 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 button1_Click_1(object sender, EventArgs e)
        {
            //try
            //{
            Int64  sood       = Int64.Parse(lblprice.Text) - Int64.Parse(lblhazine.Text);
            string DateDay    = lblsabtday.Text;
            string Year       = lblsabtyear.Text;
            string Month      = lblsabtmonth.Text;
            string Day        = lblsabtday.Text;
            string MajlesDate = cmbyear.Text + "/" + cmbmonth.Text + "/" + cmbday.Text;
            int    status;

            status = 1;
            string      type       = "0";
            string      halat      = "1";
            DBManagment objdbclass = new DBManagment();
            string      majles     = "0";
            string      takhfif;

            if (txtProtakhfif.Text == "")
            {
                takhfif = "0";
            }
            else
            {
                takhfif = txtProtakhfif.TextValue.ToString();
            }

            objdbclass.Inserttable("Insert Into Sefaresh (Sefareshid,Name,Number,Price,SumPrice,Sood,SabtDate,SabtYear,SabtMonth,SabtDay,MajlesDate,MajlesYear,MajlesMonth,MajlesDay,Des,Type,Takhfif,halat,OneSood,status) Values (N'" + Int64.Parse(lblsefareshid.Text) + "', N'" + lblname.Text + "' ,'" + Int64.Parse(txttedad.Text) + "','" + Int64.Parse(lblprice.Text) + "','" + Int64.Parse(lblprice.Text) * Int64.Parse(txttedad.Text) + "','" + sood * Int64.Parse(txttedad.Text) + "','" + DateDay + "','" + Year + "','" + Month + "','" + Day + "', '" + MajlesDate + "' , '" + cmbyear.Text + "','" + cmbmonth.Text + "','" + cmbday.Text + "','" + txtdes.Text + "','" + type + "','" + Int64.Parse(takhfif) + "','" + Int16.Parse(halat) + "','" + sood + "','" + status + "')");
            //  Loadgridview2();
            search("Select id,Name,Number,Price,SumPrice,OneSood from Sefaresh where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'");

            Int64 sum = Int64.Parse(lblprice.Text) * Int32.Parse(txttedad.Text);

            //  textBox1.Text = (Int64.Parse(textBox1.Text) + sum).ToString();
            // MessageBox.Show("  ثبت با موفقیت انجام شد");


            // 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) + "'  ");
            //}
            //catch
            //{
            //    MessageBox.Show("  عملیات ثبت امکان پذیر نمی باشد");

            //}
        }
        private void button2_Click(object sender, System.EventArgs e)
        {
            try
            {
                string ss = dataGridView1.CurrentRow.Cells[0].Value.ToString();

                DBManagment objclass = new DBManagment();
                objclass.Deleterowtable("Delete Sefaresh  where   Sefareshid='" + Int64.Parse(ss) + "' ");
                objclass.Deleterowtable("Delete SefareshMoney where Sefareshid='" + Int64.Parse(ss) + "' ");
                dataGridView1.DataSource = null;
            }
            catch
            {
                MessageBox.Show("امکان حذف مقدور نمی باشد", "توجه");
            }
        }
        private void button7_Click(object sender, EventArgs e)
        {
            try{
                DBManagment objdbclass = new DBManagment();

                objdbclass.Updatetable("Update Sefaresh Set Number='" + Int32.Parse(txtnumberrr.Text) + "',Price='" + Int32.Parse(lblPriceeee.Text) + "',SumPrice='" + Int32.Parse(lblPriceeee.Text) * Int32.Parse(txtnumberrr.Text) + "',Sood='" + Int32.Parse(label31.Text) * Int32.Parse(txtnumberrr.Text) + "' where id='" + Int64.Parse(lbliddddd.Text) + "'  ");

                MessageBox.Show("ویرایش با موفقیت انجام شد");
                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) + "'  ");
            }
            catch
            {
                MessageBox.Show("  عملیات ویرایش امکان پذیر نمی باشد");
            }
        }
Ejemplo n.º 19
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string ss = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                //  Int64 sumdelete = Int64.Parse(dataGridView2.CurrentRow.Cells[4].Value.ToString());


                DBManagment objclass = new DBManagment();
                objclass.Deleterowtable("Delete Factor where    Factorid='" + Int64.Parse(ss) + "' ");
                dataGridView1.DataSource = null;
            }
            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 button4_Click(object sender, EventArgs e)
        {
            try
            {
                string ss        = dataGridView2.CurrentRow.Cells[2].Value.ToString();
                Int64  sumdelete = Int64.Parse(dataGridView2.CurrentRow.Cells[5].Value.ToString());

                DBManagment objclass = new DBManagment();
                objclass.Deleterowtable("Delete Sefaresh where   Name=N'" + ss + "' and Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "' ");
                search("Select id,Name,Number,Price,SumPrice,OneSood 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) + "'  ");
                //  text= Int64.Parse( dataGridView2.CurrentRow.Cells[3].Value.ToString());
            }
            catch
            {
                MessageBox.Show("امکان حذف وجود ندارد", "توجه");
            }
        }
        private void btbedit_Click(object sender, EventArgs e)
        {
            try
            {
                string MajlesDate = cmbyear.Text + "/" + cmbmonth.Text + "/" + cmbday.Text;

                Int64       sefareshid = Int64.Parse(lblsefareshid.Text);
                DBManagment objdbclass = new DBManagment();

                objdbclass.Updatetable("Update Sefaresh Set Des=N'" + txtdes.Text + "',MajlesDate='" + MajlesDate + "', MajlesDay='" + cmbday.Text + "',MajlesMonth='" + cmbmonth.Text + "',MajlesYear='" + cmbyear.Text + "',Takhfif='" + Int64.Parse(txtProtakhfif.TextValue.ToString()) + "' where Sefareshid='" + sefareshid + "'  ");
                MessageBox.Show("ویرایش با موفقیت انجام شد");
                //  Loadgridview();
            }
            catch
            {
                MessageBox.Show("  عملیات ویرایش امکان پذیر نمی باشد");
            }
        }
Ejemplo n.º 23
0
        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 = "نام سفارش دهنده";
            }
        }
Ejemplo n.º 24
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("آیا برای ویرایش اطمینان دارید ؟", "توجه", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
            {
                return;
            }
            try
            {
                DBManagment objdbclass = new DBManagment();

                objdbclass.Updatetable("Update Foods Set Name=N'" + textBox2.Text + "', hazine='" + Int32.Parse(txtProhazine.TextValue.ToString()) + "',price='" + Int32.Parse(txtProforosh.TextValue.ToString()) + "' where id='" + Int32.Parse(textBox1.Text) + "'  ");
                Loadgridview();
            }
            catch
            {
                MessageBox.Show("ویرایش امکان پذیر نیست");
            }
        }
        private void button5_Click(object sender, EventArgs e)
        {
            bool successfullCreateAccount = true;

            try
            {
                Int64 sum = Int64.Parse(txtProNet1.TextValue.ToString());

                Int64  takhfifi;
                string takhfif = txtProtakhfif.TextValue.ToString();
                if (takhfif == "")
                {
                    takhfifi = Int64.Parse("0");
                }
                else
                {
                    takhfifi = Int64.Parse(txtProtakhfif.TextValue.ToString());
                    DBManagment objdbclass = new DBManagment();
                    objdbclass.Updatetable("Update Factor Set takhfif='" + Int32.Parse(txtProtakhfif.TextValue.ToString()) + "'  , status='" + int.Parse("1") + "'  where Factorid='" + Int64.Parse(txtfactorid.Text) + "'  ");
                }

                Int64 sumnahaei = sum - takhfifi;
                txtProNet2.Text = sumnahaei.ToString();
                //  txtProNet1.Text = (Int64.Parse(txtProNet1.TextValue.ToString()) + sum).ToString();
            }
            catch
            {
                successfullCreateAccount = false;
            }
            if (successfullCreateAccount)
            {
                printPreviewDialog1.Document = printDocument1;
                printPreviewDialog1.ShowDialog();
                this.Close();
            }
            if (successfullCreateAccount == false)
            {
                MessageBox.Show("امکان ثبت این فاکتور وجود ندارد", "توجه");

                DBManagment objclass = new DBManagment();
                objclass.Deleterowtable("Delete Factor where  Factorid='" + Int64.Parse(txtfactorid.Text) + "' ");
                loadgridview2();
            }
        }
Ejemplo n.º 26
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show(" اطمینان دارید ؟'" + dataGridView1.CurrentRow.Cells[1].Value.ToString() + "'آیا برای حذف اطلاعات", "توجه", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }


                int         deletecolumnid = Int32.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
                DBManagment objclass       = new DBManagment();
                objclass.Deleterowtable("Delete Foods where id='" + deletecolumnid + "' ");
                Loadgridview();
            }
            catch
            {
                MessageBox.Show("حذف امکان پذیر نیست");
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                string ss        = dataGridView2.CurrentRow.Cells[1].Value.ToString();
                Int64  sumdelete = Int64.Parse(dataGridView2.CurrentRow.Cells[4].Value.ToString());

                DBManagment objclass = new DBManagment();
                objclass.Deleterowtable("Delete Sefaresh where   Name=N'" + ss + "' and Sefareshid='" + Int64.Parse(lbfactorid.Text) + "' ");
                Loadgridview2();

                //  text= Int64.Parse( dataGridView2.CurrentRow.Cells[3].Value.ToString());
                Int64 sumfactor = Int64.Parse(txtProNet1.TextValue.ToString());

                Int64 factror = sumfactor - sumdelete;
                txtProNet1.Text = factror.ToString();
            }
            catch
            {
                MessageBox.Show("امکان حذف وجود ندارد", "توجه");
            }
        }
 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("ثبت غذا امکانپذیر نمی باشد", "توجه");
                }
            }
        }
Ejemplo n.º 30
0
        public void bedehkar()
        {
            SqlConnection  objcon1     = new SqlConnection("Data Source=Localhost;Initial Catalog=FoodDB; Integrated Security=True");
            SqlDataAdapter objadapter1 = new SqlDataAdapter("  Select SUM(Money)as SUMMoney from SefareshMoney where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "' ", objcon1);
            DataSet        objset1     = new DataSet();

            objadapter1.Fill(objset1, "SefareshMoney");
            DataRow objdatarow1 = objset1.Tables["SefareshMoney"].Rows[0];

            string summoney = objdatarow1["SUMMoney"].ToString();
            Int64  summoneyy;

            if (summoney == "")
            {
                summoneyy = Int64.Parse("0");
            }
            else
            {
                summoneyy = Int64.Parse(objdatarow1["SUMMoney"].ToString());
            }
            Int64 sumnahaei = Int64.Parse(txtProsumnahaei.TextValue.ToString());

            Int64 bedehkar = sumnahaei - summoneyy;

            txtprodiv.Text = bedehkar.ToString();
            if (bedehkar == 0)
            {
                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();
                int         halat      = int.Parse("0");
                objdbclass.Updatetable("Update SefareshMoney Set FinishYear='" + Year + "',FinishMonth='" + Month + "',FinishDay='" + Day + "'  where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'  ");


                objdbclass.Updatetable("Update Sefaresh Set halat='" + halat + "' where Sefareshid='" + Int64.Parse(txtsefareshid0.Text) + "'  ");
            }
        }