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 تغییر_فاکتور_Load(object sender, System.EventArgs e)
        {
            string      status   = "0";
            DBManagment objclass = new DBManagment();

            objclass.Deleterowtable("Delete Factor where  status='" + int.Parse(status) + "' ");
        }
        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 ثبت_سفارش_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) + "' ");
        }
Пример #7
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 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 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();
            }
        }
Пример #10
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)
        {
            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 Factor where   Name=N'" + ss + "' and Factorid='" + Int64.Parse(txtfactorid.Text) + "' ");
                loadgridview2();

                Int64 sumfactor = Int64.Parse(txtProNet1.TextValue.ToString());

                Int64 factror = sumfactor - sumdelete;
                //txtProNet1.Text = factror.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();
            }
            catch
            {
                MessageBox.Show("امکان حذف وجود ندارد", "توجه");
            }
        }
        private void button4_Click(object sender, System.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 Factor where   Name=N'" + ss + "' and Factorid='" + Int64.Parse(txtfactorid.Text) + "' ");
                loadgridview2();

                Int64 sumfactor = Int64.Parse(txtProNet1.TextValue.ToString());

                Int64 factror = sumfactor - sumdelete;
                txtProNet1.Text = factror.ToString();
                string takhfif = txtProtakhfif.TextValue.ToString();
                txtProNet2.Text = (Int64.Parse(txtProNet1.TextValue.ToString()) - Int64.Parse(takhfif)).ToString();
            }
            catch
            {
                MessageBox.Show("امکان حذف وجود ندارد", "توجه");
            }
        }
        private void button5_Click(object sender, EventArgs e)
        {
            //  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 SUM(Sood)as sumsood  from Sefaresh where Sefareshid='" + Int64.Parse(lbfactorid.Text) + "'", objcon1);
            DataSet        objset1     = new DataSet();

            objadapter1.Fill(objset1, "Sefaresh");
            DataRow objdatarow1 = objset1.Tables["Sefaresh"].Rows[0];
            string  sood        = objdatarow1["sumsood"].ToString();


            if (Int64.Parse(txtProtakhfif.TextValue.ToString()) > Int64.Parse(sood))
            {
                MessageBox.Show("امکان ثبت وجود ندارد تخفیف بیشتر از سود این فاکتور می باشد", "توجه");
            }
            else
            {
                bool   successfullCreateAccount = true;
                string test;
                try
                {
                    string takhfif;
                    if (txtProtakhfif.Text == "")
                    {
                        takhfif = "0";
                    }
                    else
                    {
                        takhfif = txtProtakhfif.TextValue.ToString();
                    }
                    string type       = "0";
                    string halat      = "1";
                    string MajlesDate = cmbyear.Text + "/" + cmbmonth.Text + "/" + cmbday.Text;
                    string dt         = cmbyear.Text + cmbmonth.Text + cmbday.Text;
                    if (txtdes.Text != "" && dt != "")
                    {
                        DBManagment objdbclass = new DBManagment();
                        objdbclass.Updatetable("Update Sefaresh Set MajlesDate='" + MajlesDate + "' ,MajlesYear='" + cmbyear.Text + "', MajlesMonth='" + cmbmonth.Text + "' ,MajlesDay='" + cmbday.Text + "',Des=N'" + txtdes.Text + "',Type='" + type + "',Takhfif='" + Int64.Parse(takhfif) + "',halat='" + Int16.Parse(halat) + "', status='" + int.Parse("1") + "'  where Sefareshid='" + Int64.Parse(lbfactorid.Text) + "'  ");

                        Int64 factor       = Int64.Parse(txtProNet1.TextValue.ToString());
                        Int64 takhfifi     = Int64.Parse(takhfif);
                        Int64 factornahaei = factor - takhfifi;
                        txtProNet2.Text = factornahaei.ToString();
                        printPreviewDialog1.Document = printDocument1;
                        printPreviewDialog1.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("برای ثبت نهایی سفارش نام سفارش دهنده و تاریخ مجلس را پر کنید");
                    }
                }
                catch
                {
                    successfullCreateAccount = false;
                }

                if (successfullCreateAccount == false)
                {
                    MessageBox.Show("امکان ثبت این فاکتور وجود ندارد", "توجه");

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