예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DataRowView row1 = (DataRowView)(((GridView)dataGridView1.MainView).GetRow(((GridView)dataGridView1.MainView).GetSelectedRows()[0]));
                if (row1 != null)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the item?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.Yes)
                    {
                        string       query  = "delete from storage where Storage_ID=" + row1[0].ToString();
                        MySqlCommand comand = new MySqlCommand(query, dbconnection);
                        dbconnection.Open();
                        comand.ExecuteNonQuery();

                        UserControl.ItemRecord("storage", "حذف", Convert.ToInt16(row1[0].ToString()), DateTime.Now, "", dbconnection);

                        displayProducts();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                    }
                }
                else
                {
                    MessageBox.Show("you must select an item");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
예제 #2
0
        void delete(GridView view)
        {
            int[] selRows = ((GridView)gridControl1.MainView).GetSelectedRows();
            if (selRows.Length > 0)
            {
                if (MessageBox.Show("هل انت متاكد انك تريد الحذف؟", "تحذير", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }

                conn.Open();
                for (int i = 0; i < selRows.Length; i++)
                {
                    DataRowView selRow = (DataRowView)(((GridView)gridControl1.MainView).GetRow(selRows[i]));

                    string       query  = "delete from customer_phone where Customer_ID=" + selRow[0].ToString();
                    MySqlCommand comand = new MySqlCommand(query, conn);
                    comand.ExecuteNonQuery();

                    query  = "delete from customer where Customer_ID=" + selRow[0].ToString();
                    comand = new MySqlCommand(query, conn);
                    comand.ExecuteNonQuery();

                    UserControl.ItemRecord("customer", "حذف", Convert.ToInt16(selRow[0].ToString()), DateTime.Now, "", conn);
                }
                conn.Close();
                search();
            }
            else
            {
                MessageBox.Show("يجب ان تختار عنصر للحذف");
            }
        }
예제 #3
0
        void delete()
        {
            string       query = "delete from area where Area_ID=" + areaId;
            MySqlCommand com   = new MySqlCommand(query, dbConnection);

            com.ExecuteNonQuery();
            UserControl.ItemRecord("area", "حذف", areaId, DateTime.Now, null, dbConnection);
        }
예제 #4
0
        void delete()
        {
            string       query = "delete from zone where Zone_ID=" + zoneId;
            MySqlCommand com   = new MySqlCommand(query, dbConnection);

            com.ExecuteNonQuery();
            UserControl.ItemRecord("zone", "حذف", zoneId, DateTime.Now, null, dbConnection);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection.Open();
                DataRowView row1 = (DataRowView)(((GridView)gridControl1.MainView).GetRow(((GridView)gridControl1.MainView).GetSelectedRows()[0]));
                if (chBoxSelectAll.Checked)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the item?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.Yes)
                    {
                        DataTable dataTable = (DataTable)gridControl1.DataSource;
                        for (int i = 0; i < dataTable.Rows.Count; i++)
                        {
                            string       query  = "delete from sellprice where SellPrice_ID='" + dataTable.Rows[i][0].ToString() + "'";
                            MySqlCommand comand = new MySqlCommand(query, dbconnection);

                            comand.ExecuteNonQuery();

                            UserControl.ItemRecord("sellprice", "حذف", Convert.ToInt16(row1[0].ToString()), DateTime.Now, "", dbconnection);
                            dbconnection.Open();
                        }
                    }
                }
                else if (row1 != null)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the item?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.Yes)
                    {
                        string       query  = "delete from sellprice where SellPrice_ID='" + row1[0].ToString() + "'";
                        MySqlCommand comand = new MySqlCommand(query, dbconnection);

                        comand.ExecuteNonQuery();

                        UserControl.ItemRecord("sellprice", "حذف", Convert.ToInt16(row1[0].ToString()), DateTime.Now, "", dbconnection);
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                    }
                }
                else
                {
                    MessageBox.Show("you must select an item");
                }

                displayProducts();
            }
            catch
            {
                MessageBox.Show("you must select an item");
            }
            dbconnection.Close();
        }
예제 #6
0
        private void btnAddNewArea_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtArea.Text != "")
                {
                    dbConnection.Open();
                    string       q = "select Area_Name from area where Area_Name='" + txtArea.Text + "'";
                    MySqlCommand c = new MySqlCommand(q, dbConnection);
                    if (c.ExecuteScalar() == null)
                    {
                        string       query = "insert into area (Area_Name) values (@Area_Name)";
                        MySqlCommand com   = new MySqlCommand(query, dbConnection);
                        com.Parameters.Add("@Area_Name", MySqlDbType.VarChar).Value = txtArea.Text;
                        com.ExecuteNonQuery();
                        txtArea.Text = "";

                        q = "select Area_ID from area order by Area_ID desc limit 1";
                        c = new MySqlCommand(q, dbConnection);
                        int areId = Convert.ToInt16(c.ExecuteScalar().ToString());

                        UserControl.ItemRecord("area", "اضافة", areId, DateTime.Now, null, dbConnection);
                        updateLists();
                        displayAllAreas();
                        MessageBox.Show("تم الاضافة");
                    }
                    else
                    {
                        MessageBox.Show("هذه المنطقة تم اضافتها من قبل");
                    }
                }
                else
                {
                    MessageBox.Show("يجب ادخال البيانات كاملة");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            dbConnection.Close();
        }
예제 #7
0
        private void radNewBill_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection.Open();
                int          id    = 0;
                string       query = "select Bill_Number from dash where Branch_ID=" + EmpBranchId + " order by Dash_ID desc limit 1";
                MySqlCommand cmd   = new MySqlCommand(query, dbconnection);
                if (cmd.ExecuteScalar() != null)
                {
                    id = Convert.ToInt16(cmd.ExecuteScalar());
                }
                id = id + 1;
                //txtBill.Visible = true;
                //labBill.Visible = true;
                //btnConfirm.Visible = true;
                txtBill.Enabled = false;
                txtBill.Text    = id.ToString();
                //txtBill.TextAlign = ContentAlignment.MiddleCenter;

                query = "insert into dash (Delegate_ID,Delegate_Name,Bill_Number,Branch_ID,Bill_Date) values (@Delegate_ID,@Delegate_Name,@Bill_Number,@Branch_ID,@Bill_Date)";
                MySqlCommand com = new MySqlCommand(query, dbconnection);
                com.Parameters.Add("@Delegate_ID", MySqlDbType.Int16).Value     = delId;
                com.Parameters.Add("@Delegate_Name", MySqlDbType.VarChar).Value = delName;
                com.Parameters.Add("@Bill_Number", MySqlDbType.Int16).Value     = id;
                com.Parameters.Add("@Branch_ID", MySqlDbType.Int16).Value       = EmpBranchId;
                com.Parameters.Add("@Bill_Date", MySqlDbType.DateTime).Value    = DateTime.Now;
                com.ExecuteNonQuery();

                string       q       = "select Dash_ID from dash where Branch_ID=" + EmpBranchId + " and Bill_Number=" + id + " order by Dash_ID desc limit 1";
                MySqlCommand command = new MySqlCommand(q, dbconnection);
                int          dashId  = Convert.ToInt16(command.ExecuteScalar().ToString());

                UserControl.ItemRecord("dash", "اضافة", dashId, DateTime.Now, null, dbconnection);
                dbconnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection.Open();
                DataRowView offerRow = (DataRowView)(((GridView)dataGridView1.MainView).GetRow(((GridView)dataGridView1.MainView).GetSelectedRows()[0]));

                if (offerRow != null)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the item?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.Yes)
                    {
                        deleteOffer(Convert.ToInt16(offerRow[0].ToString()));

                        string       query = "ALTER TABLE offer AUTO_INCREMENT = 1;";
                        MySqlCommand com   = new MySqlCommand(query, dbconnection);
                        com.ExecuteNonQuery();

                        UserControl.ItemRecord("offer", "حذف", Convert.ToInt16(offerRow[0].ToString()), DateTime.Now, "", dbconnection);
                        dbconnection.Close();
                        DisplayOffer();
                        loadDataToBox();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                    }
                }
                else
                {
                    MessageBox.Show("select row");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            dbconnection.Close();
        }
예제 #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtCode.Text != "" || chBoxSelectAll.Checked)
                {
                    dbconnection.Open();
                    double price       = double.Parse(txtPrice.Text);
                    double SellPercent = double.Parse(txtSell.Text);

                    if (radioQata3y.Checked == true)
                    {
                        #region set qata3yPrice for list item
                        if (txtCode.Text == "" && chBoxSelectAll.Checked)
                        {
                            double    NormalPercent   = double.Parse(txtNormal.Text);
                            double    UnNormalPercent = double.Parse(txtUnNormal.Text);
                            DataTable dataTable       = (DataTable)gridControl1.DataSource;
                            for (int i = 0; i < dataTable.Rows.Count; i++)
                            {
                                string       query   = "INSERT INTO sellprice (Sell_Discount,Price_Type, Sell_Price, ProfitRatio, Data_ID, Price,Last_Price, PercentageDelegate,Date) VALUES(?Sell_Discount,?Price_Type,?Sell_Price,?ProfitRatio,?Data_ID,?Price,?Last_Price,?PercentageDelegate,?Date)";
                                MySqlCommand command = new MySqlCommand(query, dbconnection);
                                command.Parameters.AddWithValue("?Price_Type", "قطعى");
                                command.Parameters.AddWithValue("?Sell_Price", calSellPrice());
                                command.Parameters.AddWithValue("?Data_ID", dataTable.Rows[i][0].ToString());
                                command.Parameters.AddWithValue("?ProfitRatio", double.Parse(txtSell.Text));
                                command.Parameters.AddWithValue("?Price", price);
                                command.Parameters.AddWithValue("?Last_Price", calSellPrice());
                                command.Parameters.AddWithValue("?Sell_Discount", 0.0);
                                command.Parameters.AddWithValue("?PercentageDelegate", double.Parse(txtPercentageDelegate.Text));
                                command.Parameters.Add("?Date", MySqlDbType.Date);
                                command.Parameters["?Date"].Value = DateTime.Now.Date;

                                command.ExecuteNonQuery();
                            }
                        }
                        #endregion
                        #region set qata3yPrice for one item
                        else
                        {
                            if (id != 0)
                            {
                                string       query   = "INSERT INTO sellprice (Sell_Discount,Price_Type,Last_Price, Sell_Price, ProfitRatio, Data_ID, Price, PercentageDelegate,Date) VALUES(?Sell_Discount,?Price_Type,?Last_Price,?Sell_Price,?ProfitRatio,?Data_ID,?Price,?PercentageDelegate,?Date)";
                                MySqlCommand command = new MySqlCommand(query, dbconnection);
                                command.Parameters.AddWithValue("?Price_Type", "قطعى");
                                command.Parameters.AddWithValue("?Sell_Price", calSellPrice());
                                command.Parameters.AddWithValue("?Data_ID", id);
                                command.Parameters.AddWithValue("?ProfitRatio", double.Parse(txtSell.Text));
                                command.Parameters.AddWithValue("?Price", price);
                                command.Parameters.AddWithValue("?Last_Price", calSellPrice());
                                command.Parameters.AddWithValue("?Sell_Discount", 0.0);
                                command.Parameters.AddWithValue("?PercentageDelegate", double.Parse(txtPercentageDelegate.Text));
                                command.Parameters.Add("?Date", MySqlDbType.Date);
                                command.Parameters["?Date"].Value = DateTime.Now.Date;


                                command.ExecuteNonQuery();
                            }
                            else
                            {
                                MessageBox.Show("error in Data_ID");
                                dbconnection.Close();
                                return;
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        #region set priceList for collection of items
                        if (txtCode.Text == "" && chBoxSelectAll.Checked)
                        {
                            double NormalPercent   = double.Parse(txtNormal.Text);
                            double unNormalPercent = double.Parse(txtUnNormal.Text);

                            double sellPrice = (price + NormalPercent) - ((price + NormalPercent) * SellPercent / 100.0);

                            sellPrice = sellPrice + unNormalPercent;
                            DataTable dataTable = (DataTable)gridControl1.DataSource;
                            for (int i = 0; i < dataTable.Rows.Count; i++)
                            {
                                string       query   = "INSERT INTO sellprice (Last_Price,Price_Type,Sell_Price,Data_ID,Sell_Discount,Price,Normal_Increase,Categorical_Increase,PercentageDelegate,Date) VALUES (?Last_Price,?Price_Type,?Sell_Price,?Data_ID,?Sell_Discount,?Price,?Normal_Increase,?Categorical_Increase,?PercentageDelegate,?Date)";
                                MySqlCommand command = new MySqlCommand(query, dbconnection);
                                command.Parameters.AddWithValue("@Price_Type", "لستة");
                                command.Parameters.AddWithValue("@Sell_Price", calSellPrice());
                                command.Parameters.AddWithValue("?Data_ID", dataTable.Rows[i][0].ToString());
                                command.Parameters.AddWithValue("@Sell_Discount", double.Parse(txtSell.Text));
                                command.Parameters.AddWithValue("@Price", price);
                                command.Parameters.AddWithValue("@Last_Price", lastPrice());
                                command.Parameters.AddWithValue("@Normal_Increase", double.Parse(txtNormal.Text));
                                command.Parameters.AddWithValue("@Categorical_Increase", double.Parse(txtUnNormal.Text));
                                command.Parameters.AddWithValue("@PercentageDelegate", double.Parse(txtPercentageDelegate.Text));
                                command.Parameters.Add("?Date", MySqlDbType.Date);
                                command.Parameters["?Date"].Value = DateTime.Now.Date;

                                command.ExecuteNonQuery();
                            }
                        }

                        #endregion
                        #region set priceList for one item
                        else
                        {
                            if (id != 0)
                            {
                                double NormalPercent   = double.Parse(txtNormal.Text);
                                double unNormalPercent = double.Parse(txtUnNormal.Text);

                                double sellPrice = (price + NormalPercent) - ((price + NormalPercent) * SellPercent / 100.0);

                                sellPrice = sellPrice + unNormalPercent;

                                string       query   = "INSERT INTO sellprice (Last_Price,Price_Type,Sell_Price,Data_ID,Sell_Discount,Price,Normal_Increase,Categorical_Increase,PercentageDelegate,Date) VALUES (?Last_Price,?Price_Type,?Sell_Price,?Data_ID,?Sell_Discount,?Price,?Normal_Increase,?Categorical_Increase,?PercentageDelegate,?Date)";
                                MySqlCommand command = new MySqlCommand(query, dbconnection);
                                command.Parameters.AddWithValue("@Price_Type", "لستة");
                                command.Parameters.AddWithValue("@Sell_Price", calSellPrice());
                                command.Parameters.AddWithValue("?Data_ID", id);
                                command.Parameters.AddWithValue("@Sell_Discount", double.Parse(txtSell.Text));
                                command.Parameters.AddWithValue("@Price", price);
                                command.Parameters.AddWithValue("@Last_Price", lastPrice());
                                command.Parameters.AddWithValue("@Normal_Increase", double.Parse(txtNormal.Text));
                                command.Parameters.AddWithValue("@Categorical_Increase", double.Parse(txtUnNormal.Text));
                                command.Parameters.AddWithValue("@PercentageDelegate", double.Parse(txtPercentageDelegate.Text));
                                command.Parameters.Add("?Date", MySqlDbType.Date);
                                command.Parameters["?Date"].Value = DateTime.Now.Date;

                                command.ExecuteNonQuery();
                            }
                            else
                            {
                                MessageBox.Show("error in Data_ID");
                                dbconnection.Close();
                                return;
                            }
                        }
                        #endregion
                    }

                    int          sellPrice_ID = 0;
                    string       queryx       = "select SellPrice_ID from sellprice order by SellPrice_ID desc limit 1";
                    MySqlCommand com          = new MySqlCommand(queryx, dbconnection);
                    if (com.ExecuteScalar() != null)
                    {
                        sellPrice_ID = Convert.ToInt16(com.ExecuteScalar());
                    }
                    foreach (DataGridViewRow item in dataGridView1.Rows)
                    {
                        double addational = Convert.ToDouble(item.Cells[0].Value);
                        queryx = "insert into additional_increase_sellprice (SellPrice_ID,AdditionalValue,Type,Description) values (@SellPrice_ID,@AdditionalValue,@Type,@Description)";
                        com    = new MySqlCommand(queryx, dbconnection);
                        com.Parameters.AddWithValue("@SellPrice_ID", sellPrice_ID);
                        com.Parameters.AddWithValue("@Type", item.Cells[1].Value);
                        com.Parameters.AddWithValue("@AdditionalValue", item.Cells[0].Value);
                        com.Parameters.AddWithValue("@Description", item.Cells[2].Value);
                        com.ExecuteNonQuery();
                    }
                    UserControl.ItemRecord("sellprice", "اضافة", sellPrice_ID, DateTime.Now, "", dbconnection);

                    MessageBox.Show("Done");
                    Clear();
                    productsSellPriceForm.displayProducts();
                }
                else
                {
                    MessageBox.Show("select item");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
예제 #10
0
        private void btnCreateOffer_Click(object sender, EventArgs e)
        {
            try
            {
                if (gridView2.SelectedRowsCount > 0 && txtOfferName.Text != "" && txtPrice.Text != "")
                {
                    string       query  = "select Offer_Name from offer where Offer_Name='" + txtOfferName.Text + "'";
                    MySqlCommand comand = new MySqlCommand(query, dbconnection);
                    dbconnection.Open();
                    MySqlDataReader dr = comand.ExecuteReader();
                    while (dr.Read())
                    {
                        if (dr["Offer_Name"].ToString() == txtOfferName.Text)
                        {
                            MessageBox.Show("هذا العرض موجود من قبل");
                            dr.Close();
                            dbconnection.Close();
                            return;
                        }
                    }
                    dr.Close();
                    dbconnection.Close();

                    double price = 0;
                    if (!double.TryParse(txtPrice.Text, out price))
                    {
                        MessageBox.Show("السعر يجب ان يكون عدد");
                        dbconnection.Close();
                        return;
                    }

                    dbconnection.Open();
                    query = "insert into offer (Offer_Name,Price,Delegate_Percent,Description) values (@Offer_Name,@Price,@Delegate_Percent,@Description)";
                    MySqlCommand com = new MySqlCommand(query, dbconnection);
                    com.Parameters.Add("@Offer_Name", MySqlDbType.VarChar);
                    com.Parameters["@Offer_Name"].Value = txtOfferName.Text;
                    com.Parameters.Add("@Price", MySqlDbType.Decimal);
                    com.Parameters["@Price"].Value = price;
                    com.Parameters.Add("@Delegate_Percent", MySqlDbType.Decimal);
                    com.Parameters["@Delegate_Percent"].Value = txtDelegatePercent.Text;
                    com.Parameters.Add("@Description", MySqlDbType.VarChar);
                    com.Parameters["@Description"].Value = txtDescription.Text;
                    com.ExecuteNonQuery();

                    query = "select Offer_ID from offer order by Offer_ID desc limit 1";
                    com   = new MySqlCommand(query, dbconnection);
                    int id = Convert.ToInt16(com.ExecuteScalar());

                    for (int i = 0; i < gridView2.RowCount; i++)
                    {
                        DataRowView item = (DataRowView)gridView2.GetRow(i);
                        query = "insert offer_details (Offer_ID,Data_ID,Quantity) values (@Offer_ID,@Data_ID,@Quantity)";
                        com   = new MySqlCommand(query, dbconnection);
                        com.Parameters.Add("@Offer_ID", MySqlDbType.Int16);
                        com.Parameters["@Offer_ID"].Value = id;
                        com.Parameters.Add("@Data_ID", MySqlDbType.Int16);
                        com.Parameters["@Data_ID"].Value = Convert.ToInt16(item[0].ToString());
                        com.Parameters.Add("@Quantity", MySqlDbType.Decimal);
                        com.Parameters["@Quantity"].Value = Convert.ToDouble(item["الكمية"].ToString());
                        com.ExecuteNonQuery();
                    }

                    if (selectedImage != null)
                    {
                        query = "insert into offer_photo (Offer_ID,Photo) values (@Offer_ID,@Photo)";
                        com   = new MySqlCommand(query, dbconnection);
                        com.Parameters.Add("@Offer_ID", MySqlDbType.Int16);
                        com.Parameters["@Offer_ID"].Value = id;
                        com.Parameters.Add("@Photo", MySqlDbType.LongBlob);
                        com.Parameters["@Photo"].Value = selectedImage;
                        com.ExecuteNonQuery();
                    }

                    UserControl.ItemRecord("offer", "اضافة", id, DateTime.Now, "", dbconnection);

                    clear(tableLayoutPanel1);
                    offerForm.DisplayOffer();
                    offerForm.loadDataToBox();
                }
                else
                {
                    MessageBox.Show("يجب ادخال البيانات كاملة");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
예제 #11
0
        void delete(GridView view)
        {
            int[] selRows = ((GridView)gridControl1.MainView).GetSelectedRows();
            // && gridView1.GetRowCellDisplayText(gridView1.GetSelectedRows()[0], "Error") == "0"
            if (selRows.Length > 0)
            {
                if (MessageBox.Show("هل انت متاكد انك تريد الحذف؟", "تحذير", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }

                Form prompt = new Form()
                {
                    Width           = 500,
                    Height          = 220,
                    FormBorderStyle = FormBorderStyle.FixedDialog,
                    Text            = "",
                    StartPosition   = FormStartPosition.CenterScreen,
                    MaximizeBox     = false,
                    MinimizeBox     = false
                };
                Label textLabel = new Label()
                {
                    Left = 340, Top = 20, Text = "ما هو سبب الحذف؟"
                };
                TextBox textBox = new TextBox()
                {
                    Left = 50, Top = 50, Width = 385, Multiline = true, Height = 80, RightToLeft = RightToLeft
                };
                Button confirmation = new Button()
                {
                    Text = "تأكيد", Left = 200, Width = 100, Top = 140, DialogResult = DialogResult.OK
                };
                prompt.Controls.Add(textBox);
                prompt.Controls.Add(confirmation);
                prompt.Controls.Add(textLabel);
                prompt.AcceptButton = confirmation;
                if (prompt.ShowDialog() == DialogResult.OK)
                {
                    if (textBox.Text != "")
                    {
                        conn.Open();
                        for (int i = 0; i < selRows.Length; i++)
                        {
                            DataRowView selRow = (DataRowView)(((GridView)gridControl1.MainView).GetRow(selRows[i]));

                            string       query  = "delete from dash_details where DashDetails_ID=" + selRow[0].ToString();
                            MySqlCommand comand = new MySqlCommand(query, conn);
                            comand.ExecuteNonQuery();
                            main.test(delegateID, billNum);

                            UserControl.ItemRecord("dash_details", "حذف", Convert.ToInt16(selRow[0].ToString()), DateTime.Now, textBox.Text, conn);
                        }
                        conn.Close();
                        search();
                    }
                    else
                    {
                        MessageBox.Show("يجب كتابة السبب");
                    }
                }
                else
                {
                }
            }
            else
            {
                MessageBox.Show("تاكد من اختيارك");
            }
        }
예제 #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Customer_Type == "عميل" && flag)
                {
                    if (comEnginner.Text != "")
                    {
                    }
                    else
                    {
                        MessageBox.Show("يجب اختيار الضامن");
                        dbconnection.Close();
                        return;
                    }
                }
                Form prompt = new Form()
                {
                    Width           = 500,
                    Height          = 220,
                    FormBorderStyle = FormBorderStyle.FixedDialog,
                    Text            = "",
                    StartPosition   = FormStartPosition.CenterScreen,
                    MaximizeBox     = false,
                    MinimizeBox     = false
                };
                Label textLabel = new Label()
                {
                    Left = 340, Top = 20, Text = "ما هو سبب التعديل؟"
                };
                TextBox textBox = new TextBox()
                {
                    Left = 50, Top = 50, Width = 385, Multiline = true, Height = 80, RightToLeft = RightToLeft
                };
                Button confirmation = new Button()
                {
                    Text = "تأكيد", Left = 200, Width = 100, Top = 140, DialogResult = DialogResult.OK
                };
                prompt.Controls.Add(textBox);
                prompt.Controls.Add(confirmation);
                prompt.Controls.Add(textLabel);
                prompt.AcceptButton = confirmation;
                if (prompt.ShowDialog() == DialogResult.OK)
                {
                    if (textBox.Text != "")
                    {
                        dbconnection.Open();
                        string       query = "update customer set Customer_NationalID=@Customer_NationalID,Customer_Email=@Customer_Email,Customer_Address=@Customer_Address,Customer_Info=@Customer_Info,Customer_Type=@Customer_Type where Customer_ID=" + selRow[0].ToString();
                        MySqlCommand com   = new MySqlCommand(query, dbconnection);
                        com.Parameters.Add("@Customer_Address", MySqlDbType.VarChar, 255);
                        com.Parameters["@Customer_Address"].Value = txtAddress.Text;
                        com.Parameters.Add("@Customer_Email", MySqlDbType.VarChar, 255);
                        com.Parameters["@Customer_Email"].Value = txtEmail.Text;
                        if (txtNationalID.Text != "")
                        {
                            com.Parameters.Add("@Customer_NationalID", MySqlDbType.VarChar, 255);
                            com.Parameters["@Customer_NationalID"].Value = txtNationalID.Text;
                        }
                        else
                        {
                            com.Parameters.Add("@Customer_NationalID", MySqlDbType.VarChar, 255);
                            com.Parameters["@Customer_NationalID"].Value = null;
                        }
                        com.Parameters.Add("@Customer_Info", MySqlDbType.VarChar, 255);
                        com.Parameters["@Customer_Info"].Value = txtINF.Text;
                        if (Customer_Type != "")
                        {
                            com.Parameters.Add("@Customer_Type", MySqlDbType.VarChar, 255);
                            com.Parameters["@Customer_Type"].Value = Customer_Type;
                        }
                        else
                        {
                            MessageBox.Show("برجاء اختيار النوع");
                            dbconnection.Close();
                            return;
                        }
                        com.ExecuteNonQuery();
                        if (Customer_Type == "عميل" && flag)
                        {
                            AddClientToEng_Con();
                        }

                        UserControl.ItemRecord("customer", "تعديل", Convert.ToInt16(selRow[0].ToString()), DateTime.Now, textBox.Text, dbconnection);

                        //MessageBox.Show("تم");
                        //clear();
                        xtraTabPage.ImageOptions.Image = null;
                        MainForm.objFormCustomer.search();
                        MainForm.tabControlSales.TabPages.Remove(MainForm.MainTabPageUpdateCustomer);
                    }
                    else
                    {
                        MessageBox.Show("يجب كتابة السبب");
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
예제 #13
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection.Open();
                double price       = double.Parse(txtPrice.Text);
                double SellPercent = double.Parse(txtSell.Text);

                if (radioQata3y.Checked == true)
                {
                    #region set qata3yPrice for list item

                    double NormalPercent   = double.Parse(txtNormal.Text);
                    double UnNormalPercent = double.Parse(txtUnNormal.Text);

                    DataTable dataTable = (DataTable)gridControl1.DataSource;
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        String query = "update sellprice set Sell_Discount=@Sell_Discount,Normal_Increase=@Normal_Increase,Categorical_Increase=@Categorical_Increase,Price_Type=@Price_Type,Sell_Price=@Sell_Price,ProfitRatio=@ProfitRatio,Price=@Price,PercentageDelegate=@PercentageDelegate where SellPrice_ID=" + dataTable.Rows[i][0].ToString();

                        MySqlCommand command = new MySqlCommand(query, dbconnection);
                        command.Parameters.AddWithValue("@Price_Type", "قطعى");
                        command.Parameters.AddWithValue("@Sell_Price", price + (price * SellPercent / 100.0));
                        command.Parameters.AddWithValue("@ProfitRatio", SellPercent);
                        command.Parameters.AddWithValue("@Sell_Discount", 0.00);
                        command.Parameters.AddWithValue("@Price", price);
                        command.Parameters.AddWithValue("@Normal_Increase", 0.00);
                        command.Parameters.AddWithValue("@Categorical_Increase", 0.00);
                        command.Parameters.AddWithValue("@PercentageDelegate", double.Parse(txtPercentageDelegate.Text));

                        command.ExecuteNonQuery();

                        UserControl.ItemRecord("sellprice", "تعديل", Convert.ToInt16(dataTable.Rows[i][0].ToString()), DateTime.Now, "", dbconnection);
                        dbconnection.Open();
                    }

                    #endregion
                }
                else
                {
                    #region set priceList for collection of items

                    double NormalPercent   = double.Parse(txtNormal.Text);
                    double unNormalPercent = double.Parse(txtUnNormal.Text);

                    double sellPrice = (price + NormalPercent) - ((price + NormalPercent) * SellPercent / 100.0);

                    sellPrice = sellPrice + unNormalPercent;

                    DataTable dataTable = (DataTable)gridControl1.DataSource;
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        string query = "update sellprice set ProfitRatio=@ProfitRatio, Price_Type=@Price_Type,Sell_Price=@Sell_Price,Sell_Discount=@Sell_Discount,Price=@Price,Normal_Increase=@Normal_Increase,Categorical_Increase=@Categorical_Increase,PercentageDelegate=@PercentageDelegate where SellPrice_ID =" + dataTable.Rows[i][0].ToString();

                        MySqlCommand command = new MySqlCommand(query, dbconnection);
                        command.Parameters.AddWithValue("@Price_Type", "لستة");
                        command.Parameters.AddWithValue("@Sell_Price", sellPrice);
                        command.Parameters.AddWithValue("@ProfitRatio", 0.00);
                        command.Parameters.AddWithValue("@Sell_Discount", double.Parse(txtSell.Text));
                        command.Parameters.AddWithValue("@Price", price);
                        command.Parameters.AddWithValue("@Normal_Increase", double.Parse(txtNormal.Text));
                        command.Parameters.AddWithValue("@Categorical_Increase", double.Parse(txtUnNormal.Text));
                        command.Parameters.AddWithValue("@PercentageDelegate", double.Parse(txtPercentageDelegate.Text));

                        command.ExecuteNonQuery();

                        UserControl.ItemRecord("sellprice", "تعديل", Convert.ToInt16(dataTable.Rows[i][0].ToString()), DateTime.Now, "", dbconnection);
                        dbconnection.Open();
                    }

                    #endregion
                }
                displayData();

                productsSellPriceForm.displayProducts();

                XtraTabPage xtraTabPage = getTabPage("تعديل اسعار البنود");

                xtraTabPage.ImageOptions.Image = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
예제 #14
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int[] selRows = ((GridView)gridControl1.MainView).GetSelectedRows();
                if (selRows.Length > 0)
                {
                    if (MessageBox.Show("هل انت متاكد انك تريد الحذف؟", "تحذير", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        return;
                    }

                    Form prompt = new Form()
                    {
                        Width           = 500,
                        Height          = 220,
                        FormBorderStyle = FormBorderStyle.FixedDialog,
                        Text            = "",
                        StartPosition   = FormStartPosition.CenterScreen,
                        MaximizeBox     = false,
                        MinimizeBox     = false
                    };
                    Label textLabel = new Label()
                    {
                        Left = 340, Top = 20, Text = "ما هو سبب الحذف؟"
                    };
                    TextBox textBox = new TextBox()
                    {
                        Left = 50, Top = 50, Width = 385, Multiline = true, Height = 80, RightToLeft = RightToLeft
                    };
                    Button confirmation = new Button()
                    {
                        Text = "تأكيد", Left = 200, Width = 100, Top = 140, DialogResult = DialogResult.OK
                    };
                    prompt.Controls.Add(textBox);
                    prompt.Controls.Add(confirmation);
                    prompt.Controls.Add(textLabel);
                    prompt.AcceptButton = confirmation;
                    if (prompt.ShowDialog() == DialogResult.OK)
                    {
                        if (textBox.Text != "")
                        {
                            conn.Open();
                            for (int i = 0; i < gridView1.SelectedRowsCount; i++)
                            {
                                DataRowView  selRow    = (DataRowView)(((GridView)gridControl1.MainView).GetRow(selRows[i]));
                                string       Query     = "update attendance set Error=1 where Attendance_ID=" + Convert.ToInt16(selRow[0].ToString());
                                MySqlCommand MyCommand = new MySqlCommand(Query, conn);
                                MyCommand.ExecuteNonQuery();

                                UserControl.ItemRecord("attendance", "حذف", Convert.ToInt16(selRow[0].ToString()), DateTime.Now, textBox.Text, conn);
                            }
                            search();
                        }
                        else
                        {
                            MessageBox.Show("يجب كتابة السبب");
                        }
                    }
                    else
                    {
                    }
                }
                else
                {
                    MessageBox.Show("يجب ان تختار عنصر للحذف");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            conn.Close();
        }
예제 #15
0
        private void btnCreateOffer_Click(object sender, EventArgs e)
        {
            try
            {
                if (gridView2.SelectedRowsCount > 0 && txtPrice.Text != "")
                {
                    double price = 0;
                    if (!double.TryParse(txtPrice.Text, out price))
                    {
                        MessageBox.Show("السعر يجب ان يكون عدد");
                        dbconnection.Close();
                        return;
                    }

                    dbconnection.Open();
                    string       query = "update offer set Price=@Price,Delegate_Percent=@Delegate_Percent,Description=@Description where Offer_ID=" + rowOffer[0].ToString();
                    MySqlCommand com   = new MySqlCommand(query, dbconnection);
                    com.Parameters.Add("@Price", MySqlDbType.Decimal);
                    com.Parameters["@Price"].Value = price;
                    com.Parameters.Add("@Delegate_Percent", MySqlDbType.Decimal);
                    com.Parameters["@Delegate_Percent"].Value = txtDelegatePercent.Text;
                    com.Parameters.Add("@Description", MySqlDbType.VarChar);
                    com.Parameters["@Description"].Value = txtDescription.Text;
                    com.ExecuteNonQuery();

                    //فك كمية البنود
                    dbconnection3.Open();
                    query = "select storage.Store_ID,sum(Total_Meters) as 'الكمية' from storage  where Offer_ID=" + rowOffer[0].ToString() + " group by storage.Store_ID,storage.Offer_ID";
                    com   = new MySqlCommand(query, dbconnection3);
                    MySqlDataReader dr = com.ExecuteReader();
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            RecordOfferQuantityInStorage(Convert.ToInt16(rowOffer[0].ToString()), Convert.ToInt16(dr["Store_ID"].ToString()));
                            increaseItemsQuantityInDB(Convert.ToDouble(dr["الكمية"].ToString()), Convert.ToInt16(rowOffer[0].ToString()), Convert.ToInt16(dr["Store_ID"].ToString()));
                        }
                        dr.Close();
                    }
                    ////////////////////

                    query = "delete from offer_details where Offer_ID=" + rowOffer[0].ToString();
                    com   = new MySqlCommand(query, dbconnection);
                    com.ExecuteNonQuery();

                    for (int i = 0; i < gridView2.RowCount; i++)
                    {
                        DataRowView item = (DataRowView)gridView2.GetRow(i);
                        query = "insert offer_details (Offer_ID,Data_ID,Quantity) values (@Offer_ID,@Data_ID,@Quantity)";
                        com   = new MySqlCommand(query, dbconnection);
                        com.Parameters.Add("@Offer_ID", MySqlDbType.Int16);
                        com.Parameters["@Offer_ID"].Value = rowOffer[0].ToString();
                        com.Parameters.Add("@Data_ID", MySqlDbType.Int16);
                        com.Parameters["@Data_ID"].Value = Convert.ToInt16(item[0].ToString());
                        com.Parameters.Add("@Quantity", MySqlDbType.Decimal);
                        com.Parameters["@Quantity"].Value = Convert.ToDouble(item["الكمية"].ToString());
                        com.ExecuteNonQuery();
                    }

                    if (selectedImage != null)
                    {
                        //selectedImage = ImageToByte(ImageProduct.Image);
                        query = "select Photo from offer_photo where Offer_ID=" + rowOffer[0].ToString();
                        com   = new MySqlCommand(query, dbconnection);
                        if (com.ExecuteScalar() != null)
                        {
                            query = "update offer_photo set Photo=@Photo where Offer_ID=" + rowOffer[0].ToString();
                            com   = new MySqlCommand(query, dbconnection);
                            com.Parameters.Add("@Photo", MySqlDbType.LongBlob);
                            com.Parameters["@Photo"].Value = selectedImage;
                            com.ExecuteNonQuery();
                        }
                        else
                        {
                            query = "insert into offer_photo (Offer_ID,Photo) values (@Offer_ID,@Photo)";
                            com   = new MySqlCommand(query, dbconnection);
                            com.Parameters.Add("@Offer_ID", MySqlDbType.Int16);
                            com.Parameters["@Offer_ID"].Value = rowOffer[0].ToString();
                            com.Parameters.Add("@Photo", MySqlDbType.LongBlob);
                            com.Parameters["@Photo"].Value = selectedImage;
                            com.ExecuteNonQuery();
                        }
                    }
                    else
                    {
                        query = "select Photo from offer_photo where Offer_ID=" + rowOffer[0].ToString();
                        com   = new MySqlCommand(query, dbconnection);
                        if (com.ExecuteScalar() != null)
                        {
                            query = "delete from offer_photo where Offer_ID=" + rowOffer[0].ToString();
                            com   = new MySqlCommand(query, dbconnection);
                            com.ExecuteNonQuery();
                        }
                    }

                    UserControl.ItemRecord("offer", "تعديل", Convert.ToInt16(rowOffer[0].ToString()), DateTime.Now, "", dbconnection);

                    //clear(tableLayoutPanel1);
                    offerForm.DisplayOffer();
                    offerForm.loadDataToBox();
                    XtraTabPage xtraTabPage = getTabPage("تعديل عرض");
                    tabControlSalesContent.TabPages.Remove(xtraTabPage);
                }
                else
                {
                    MessageBox.Show("يجب ادخال البيانات كاملة");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
            dbconnection1.Close();
            dbconnection2.Close();
            dbconnection3.Close();
        }
예제 #16
0
        private void addNewZone()
        {
            if (txtZoneNameAdd.Text != "")
            {
                bool         flag = false;
                string       q    = "select Zone_Name from zone where Zone_Name='" + txtZoneNameAdd.Text + "'";
                MySqlCommand c    = new MySqlCommand(q, dbConnection);
                if (c.ExecuteScalar() == null)
                {
                    int zonId = 0;
                    foreach (DataRowView item in checkedListBoxAreas.CheckedItems)
                    {
                        string areaName = item["Area_Name"].ToString();
                        if (!flag)
                        {
                            flag = true;

                            string       query = "insert into zone (Zone_Name) values (@Zone_Name)";
                            MySqlCommand com   = new MySqlCommand(query, dbConnection);
                            com.Parameters.Add("@Zone_Name", MySqlDbType.VarChar).Value = txtZoneNameAdd.Text;
                            com.ExecuteNonQuery();

                            q     = "select Zone_ID from zone order by Zone_ID desc limit 1";
                            c     = new MySqlCommand(q, dbConnection);
                            zonId = Convert.ToInt16(c.ExecuteScalar().ToString());

                            /*q = "select Zone_ID from area where Area_ID="+ item["Area_ID"].ToString();
                             * c = new MySqlCommand(q, dbConnection);
                             * if (c.ExecuteScalar() == null)
                             * {*/
                            query = "update area set Zone_ID=@Zone_ID where area_ID=" + item["Area_ID"].ToString();
                            com   = new MySqlCommand(query, dbConnection);
                            com.Parameters.Add("@Zone_ID", MySqlDbType.VarChar).Value = zonId;
                            com.ExecuteNonQuery();

                            /*}
                             * else
                             * {}*/
                        }
                        else
                        {
                            string       query2 = "update area set Zone_ID=@Zone_ID where area_ID=" + item["Area_ID"].ToString();
                            MySqlCommand com    = new MySqlCommand(query2, dbConnection);
                            com.Parameters.Add("@Zone_ID", MySqlDbType.VarChar).Value = zonId;
                            com.ExecuteNonQuery();
                        }
                    }
                    if (!flag)
                    {
                        string       query = "insert into zone (Zone_Name) values (@Zone_Name)";
                        MySqlCommand com   = new MySqlCommand(query, dbConnection);
                        com.Parameters.Add("@Zone_Name", MySqlDbType.VarChar).Value = txtZoneNameAdd.Text;
                        com.ExecuteNonQuery();
                    }

                    UserControl.ItemRecord("zone", "اضافة", zoneId, DateTime.Now, null, dbConnection);

                    updateLists();//update combox1
                    displayAllZones();
                    panelUpdateZone.Visible = false;
                    panelAddZone.Visible    = false;
                    MessageBox.Show("تم الاضافة");
                }
                else
                {
                    MessageBox.Show("هذه الزون تم اضافتها من قبل");
                    dbConnection.Close();
                    return;
                }
            }
            else
            {
                MessageBox.Show("يجب ادخال الاسم");
                dbConnection.Close();
                return;
            }
        }
예제 #17
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView2.Rows.Count > 0)
                {
                    if (txtSetName.Text != "")
                    {
                        string       query  = "select Set_Name from sets where Set_Name='" + txtSetName.Text + "'";
                        MySqlCommand comand = new MySqlCommand(query, dbconnection);
                        dbconnection.Open();
                        MySqlDataReader dr = comand.ExecuteReader();
                        while (dr.Read())
                        {
                            if (dr["Set_Name"].ToString() == txtSetName.Text)
                            {
                                MessageBox.Show("this set already exist");
                                dr.Close();
                                dbconnection.Close();
                                return;
                            }
                        }
                        dr.Close();

                        if (selectedImage == null)
                        {
                            query  = "INSERT INTO sets (Set_Name,Factory_ID,Type_ID,Group_ID) VALUES (@Set_Name,@Factory_ID,@Type_ID,@Group_ID)";
                            comand = new MySqlCommand(query, dbconnection);
                            comand.Parameters.AddWithValue("@Set_Name", txtSetName.Text);
                            string       q   = "select Type_ID from type where Type_Name='" + dataGridView2.Rows[0].Cells[3].Value.ToString() + "'";
                            MySqlCommand com = new MySqlCommand(q, dbconnection);
                            comand.Parameters.Add("@Type_ID", MySqlDbType.Int16);
                            comand.Parameters["@Type_ID"].Value = com.ExecuteScalar();

                            q   = "select Factory_ID from factory where Factory_Name='" + dataGridView2.Rows[0].Cells[4].Value.ToString() + "'";
                            com = new MySqlCommand(q, dbconnection);
                            comand.Parameters.Add("@Factory_ID", MySqlDbType.Int16);
                            comand.Parameters["@Factory_ID"].Value = com.ExecuteScalar();

                            q   = "select Group_ID from groupo where Group_Name='" + dataGridView2.Rows[0].Cells[5].Value.ToString() + "'";
                            com = new MySqlCommand(q, dbconnection);
                            comand.Parameters.Add("@Group_ID", MySqlDbType.Int16);
                            comand.Parameters["@Group_ID"].Value = com.ExecuteScalar();
                            comand.ExecuteNonQuery();
                        }
                        else
                        {
                            query  = "INSERT INTO sets (Set_Name,Factory_ID,Type_ID,Group_ID) VALUES (@Set_Name,@Factory_ID,@Type_ID,@Group_ID)";
                            comand = new MySqlCommand(query, dbconnection);
                            comand.Parameters.AddWithValue("@Set_Name", txtSetName.Text);
                            string       q   = "select Type_ID from type where Type_Name='" + dataGridView2.Rows[0].Cells[3].Value.ToString() + "'";
                            MySqlCommand com = new MySqlCommand(q, dbconnection);
                            comand.Parameters.Add("@Type_ID", MySqlDbType.Int16);
                            comand.Parameters["@Type_ID"].Value = com.ExecuteScalar();

                            q   = "select Factory_ID from factory where Factory_Name='" + dataGridView2.Rows[0].Cells[4].Value.ToString() + "'";
                            com = new MySqlCommand(q, dbconnection);
                            comand.Parameters.Add("@Factory_ID", MySqlDbType.Int16);
                            comand.Parameters["@Factory_ID"].Value = com.ExecuteScalar();

                            q   = "select Group_ID from groupo where Group_Name='" + dataGridView2.Rows[0].Cells[5].Value.ToString() + "'";
                            com = new MySqlCommand(q, dbconnection);
                            comand.Parameters.Add("@Group_ID", MySqlDbType.Int16);
                            comand.Parameters["@Group_ID"].Value = com.ExecuteScalar();


                            comand.ExecuteNonQuery();
                        }

                        query  = "select Set_ID from sets order by Set_ID desc limit 1";
                        comand = new MySqlCommand(query, dbconnection);
                        int set_id = Convert.ToInt16(comand.ExecuteScalar().ToString());

                        foreach (DataGridViewRow item in dataGridView2.Rows)
                        {
                            query  = "INSERT INTO set_Details (Set_ID,Data_ID,Quantity) VALUES (@Set_ID,@Data_ID,@Quantity)";
                            comand = new MySqlCommand(query, dbconnection);
                            comand.Parameters.AddWithValue("@Set_ID", set_id);
                            comand.Parameters.AddWithValue("@Data_ID", item.Cells[0].Value);
                            comand.Parameters.AddWithValue("@Quantity", double.Parse(item.Cells[2].Value.ToString()));
                            comand.ExecuteNonQuery();
                        }

                        query  = "INSERT INTO set_photo (Set_ID,Photo) VALUES (@Set_ID,@Photo)";
                        comand = new MySqlCommand(query, dbconnection);
                        comand.Parameters.AddWithValue("@Set_ID", set_id);
                        comand.Parameters.Add("@Photo", MySqlDbType.LongBlob);
                        comand.Parameters["@Photo"].Value = selectedImage;
                        comand.ExecuteNonQuery();

                        UserControl.ItemRecord("sets", "add", Convert.ToInt16(set_id.ToString()), DateTime.Now, "", dbconnection);

                        MessageBox.Show("Done");
                        clear();
                        ataqm.DisplayAtaqm();
                    }
                    else
                    {
                        MessageBox.Show("Please fill all fields with right format");
                    }
                }
                else
                {
                    MessageBox.Show("Please insert at least one item");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
예제 #18
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtQuantity.Text != "" && comStore.Text != "")
                {
                    double quantity = 0;
                    if (double.TryParse(txtQuantity.Text, out quantity))
                    {
                        conn.Open();
                        if (!checkQuantityInStore(quantity))
                        {
                            MessageBox.Show("لا يوجد كمية كافية من العنصر فى المخزن");
                            conn.Close();
                            return;
                        }

                        cartons = 0;
                        if (selRow["الكود"].ToString().Length >= 20)
                        {
                            string       q = "select Carton from data where Code='" + selRow["الكود"].ToString() + "'";
                            MySqlCommand c = new MySqlCommand(q, conn);
                            if (c.ExecuteScalar() != null)
                            {
                                if (Convert.ToDouble(c.ExecuteScalar().ToString()) > 0)
                                {
                                    if (cartonNumCheck())
                                    {
                                    }
                                    else
                                    {
                                        conn.Close();
                                        return;
                                    }
                                }
                            }
                        }

                        Form prompt = new Form()
                        {
                            Width           = 500,
                            Height          = 220,
                            FormBorderStyle = FormBorderStyle.FixedDialog,
                            Text            = "",
                            StartPosition   = FormStartPosition.CenterScreen,
                            MaximizeBox     = false,
                            MinimizeBox     = false
                        };
                        Label textLabel = new Label()
                        {
                            Left = 340, Top = 20, Text = "ما هو سبب التعديل؟"
                        };
                        TextBox textBox = new TextBox()
                        {
                            Left = 50, Top = 50, Width = 385, Multiline = true, Height = 80, RightToLeft = RightToLeft
                        };
                        Button confirmation = new Button()
                        {
                            Text = "تأكيد", Left = 200, Width = 100, Top = 140, DialogResult = DialogResult.OK
                        };
                        prompt.Controls.Add(textBox);
                        prompt.Controls.Add(confirmation);
                        prompt.Controls.Add(textLabel);
                        prompt.AcceptButton = confirmation;
                        if (prompt.ShowDialog() == DialogResult.OK)
                        {
                            if (textBox.Text != "")
                            {
                                /*string query = "select sum(storage.Total_Meters) from storage where storage.Code='" + selRow["الكود"].ToString() + "' group by storage.Code";
                                 * MySqlCommand comand = new MySqlCommand(query, conn);
                                 * double TotalMeters = Convert.ToDouble(comand.ExecuteScalar());*/

                                //quantity <= TotalMeters

                                string       query  = "update dash_details set Quantity=" + quantity + ",Cartons=" + cartons + ", Store_ID=" + comStore.SelectedValue.ToString() + " , Store_Name='" + comStore.Text + "' where DashDetails_ID=" + Convert.ToInt16(selRow[0].ToString());
                                MySqlCommand comand = new MySqlCommand(query, conn);
                                comand.ExecuteNonQuery();

                                UserControl.ItemRecord("dash_details", "تعديل", Convert.ToInt16(selRow[0].ToString()), DateTime.Now, textBox.Text, conn);

                                conn.Close();
                                MainForm.ProductsDetailsReport.loadFunc();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("يجب كتابة السبب");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("الكمية يجب ان تكون عدد");
                    }
                }
                else
                {
                    MessageBox.Show("يجب ادخال البيانات كاملة");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            conn.Close();
        }
예제 #19
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection.Open();
                if (!chBoxSpecialIncrease.Checked)
                {
                    double price       = double.Parse(txtPrice.Text);
                    double SellPercent = double.Parse(txtSell.Text);

                    if (radioQata3y.Checked == true)
                    {
                        #region set qata3yPrice for list item

                        double NormalPercent   = double.Parse(txtNormal.Text);
                        double UnNormalPercent = double.Parse(txtUnNormal.Text);

                        DataTable dataTable = (DataTable)gridControl1.DataSource;
                        for (int i = 0; i < dataTable.Rows.Count; i++)
                        {
                            String query = "update sellprice set Sell_Discount=@Sell_Discount,Normal_Increase=@Normal_Increase,Categorical_Increase=@Categorical_Increase,Price_Type=@Price_Type,Sell_Price=@Sell_Price,ProfitRatio=@ProfitRatio,Price=@Price,PercentageDelegate=@PercentageDelegate where SellPrice_ID=" + dataTable.Rows[i][0].ToString();

                            MySqlCommand command = new MySqlCommand(query, dbconnection);
                            command.Parameters.AddWithValue("@Price_Type", "قطعى");
                            command.Parameters.AddWithValue("@Sell_Price", price + (price * SellPercent / 100.0));
                            command.Parameters.AddWithValue("@ProfitRatio", SellPercent);
                            command.Parameters.AddWithValue("@Sell_Discount", 0.00);
                            command.Parameters.AddWithValue("@Price", price);
                            command.Parameters.AddWithValue("@Normal_Increase", 0.00);
                            command.Parameters.AddWithValue("@Categorical_Increase", 0.00);
                            command.Parameters.AddWithValue("@PercentageDelegate", double.Parse(txtPercentageDelegate.Text));

                            command.ExecuteNonQuery();
                        }

                        #endregion
                    }
                    else
                    {
                        #region set priceList for collection of items

                        double NormalPercent   = double.Parse(txtNormal.Text);
                        double unNormalPercent = double.Parse(txtUnNormal.Text);

                        double sellPrice = (price + NormalPercent) - ((price + NormalPercent) * SellPercent / 100.0);

                        sellPrice = sellPrice + unNormalPercent;

                        DataTable dataTable = (DataTable)gridControl1.DataSource;
                        for (int i = 0; i < dataTable.Rows.Count; i++)
                        {
                            string query = "update sellprice set ProfitRatio=@ProfitRatio, Price_Type=@Price_Type,Sell_Price=@Sell_Price,Sell_Discount=@Sell_Discount,Price=@Price,Normal_Increase=@Normal_Increase,Categorical_Increase=@Categorical_Increase,PercentageDelegate=@PercentageDelegate where SellPrice_ID =" + dataTable.Rows[i][0].ToString();

                            MySqlCommand command = new MySqlCommand(query, dbconnection);
                            command.Parameters.AddWithValue("@Price_Type", "لستة");
                            command.Parameters.AddWithValue("@Sell_Price", sellPrice);
                            command.Parameters.AddWithValue("@ProfitRatio", 0.00);
                            command.Parameters.AddWithValue("@Sell_Discount", double.Parse(txtSell.Text));
                            command.Parameters.AddWithValue("@Price", price);
                            command.Parameters.AddWithValue("@Normal_Increase", double.Parse(txtNormal.Text));
                            command.Parameters.AddWithValue("@Categorical_Increase", double.Parse(txtUnNormal.Text));
                            command.Parameters.AddWithValue("@PercentageDelegate", double.Parse(txtPercentageDelegate.Text));

                            command.ExecuteNonQuery();
                        }

                        #endregion
                    }
                    int          sellPrice_ID = 0;
                    string       queryx       = "select SellPrice_ID from sellprice order by SellPrice_ID desc limit 1";
                    MySqlCommand com          = new MySqlCommand(queryx, dbconnection);
                    if (com.ExecuteScalar() != null)
                    {
                        sellPrice_ID = Convert.ToInt16(com.ExecuteScalar());
                    }

                    queryx = "delete from additional_increase_sellprice where SellPrice_ID=" + sellPrice_ID;
                    com    = new MySqlCommand(queryx, dbconnection);
                    com.ExecuteNonQuery();

                    foreach (DataGridViewRow item in dataGridView1.Rows)
                    {
                        double addational = Convert.ToDouble(item.Cells[0].Value);
                        queryx = "insert into additional_increase_sellprice (SellPrice_ID,AdditionalValue,Type,Description) values (@SellPrice_ID,@AdditionalValue,@Type,@Description)";
                        com    = new MySqlCommand(queryx, dbconnection);
                        com.Parameters.AddWithValue("@SellPrice_ID", sellPrice_ID);
                        com.Parameters.AddWithValue("@Type", item.Cells[1].Value);
                        com.Parameters.AddWithValue("@AdditionalValue", item.Cells[0].Value);
                        com.Parameters.AddWithValue("@Description", item.Cells[2].Value);
                        com.ExecuteNonQuery();
                    }
                    UserControl.ItemRecord("sellprice", "تعديل", sellPrice_ID, DateTime.Now, "", dbconnection);
                }
                else
                {
                    double       addationalValue = 0.0;
                    DataGridView DataGridView    = (DataGridView)panContent.Controls["panContent"].Controls["dataGridView1"];
                    foreach (DataGridViewRow item1 in DataGridView.Rows)
                    {
                        addationalValue += Convert.ToDouble(item1.Cells[0].Value);
                    }
                    int[] rows = (((GridView)gridControl1.MainView).GetSelectedRows());
                    List <DataRowView> recordList = new List <DataRowView>();
                    for (int i = 0; i < rows.Length; i++)
                    {
                        DataRowView a = (DataRowView)(((GridView)gridControl1.MainView).GetRow(rows[i]));
                        recordList.Add(a);
                    }
                    foreach (DataRowView item in recordList)
                    {
                        String query = "update sellprice set Sell_Price=@Sell_Price where SellPrice_ID=" + item[0].ToString();

                        MySqlCommand command = new MySqlCommand(query, dbconnection);
                        command.Parameters.AddWithValue("@Sell_Price", Convert.ToDouble(item["سعر البيع"]) + addationalValue);
                        command.ExecuteNonQuery();

                        foreach (DataGridViewRow item1 in DataGridView.Rows)
                        {
                            double       addational = Convert.ToDouble(item1.Cells[0].Value);
                            string       queryx     = "insert into special_increase (SellPrice_ID,Value,Description,Date) values (@SellPrice_ID,@Value,@Description,@Date)";
                            MySqlCommand com        = new MySqlCommand(queryx, dbconnection);
                            com.Parameters.AddWithValue("@SellPrice_ID", item[0]);
                            com.Parameters.AddWithValue("@Value", item1.Cells[0].Value);
                            com.Parameters.AddWithValue("@Description", item1.Cells[1].Value);
                            com.Parameters.Add("@Date", MySqlDbType.Date);
                            com.Parameters["@Date"].Value = DateTime.Now.Date;
                            com.ExecuteNonQuery();
                        }
                    }
                }
                displayData();
                productsSellPriceForm.displayProducts();

                XtraTabPage xtraTabPage = getTabPage("تعديل اسعار البنود");
                xtraTabPage.ImageOptions.Image = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dbconnection.Close();
        }
예제 #20
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtFactory.Text != "" && txtGroup.Text != "" && txtProduct.Text != "" && txtType.Text != "")
                {
                    int    color_id = 0;
                    int    size_id = 0;
                    int    sort_id = 0;
                    double carton = 0;
                    string classification, description = "";
                    if (comColour.Text != "")
                    {
                        color_id = Convert.ToInt16(txtColor.Text);
                    }
                    if (comSize.Text != "")
                    {
                        size_id = Convert.ToInt16(txtSize.Text);
                    }
                    if (comSort.Text != "")
                    {
                        sort_id = Convert.ToInt16(txtSort.Text);
                    }
                    if (txtCarton.Text != "")
                    {
                        if (double.TryParse(txtCarton.Text, out carton))
                        {
                        }
                        else
                        {
                            MessageBox.Show("carton must be numeric");
                            return;
                        }
                    }
                    classification = txtClassification.Text;
                    description    = txtDescription.Text;

                    string       q      = "SELECT Data_ID from data where Color_ID=" + color_id + " and Size_ID=" + size_id + " and Sort_ID=" + sort_id + " and Description='" + description + "' and Carton=" + carton + " and Type_ID=" + txtType.Text + " and Factory_ID=" + txtFactory.Text + " and Group_ID=" + txtGroup.Text + " and Product_ID=" + txtProduct.Text + " and Classification='" + classification + "'";
                    MySqlCommand comand = new MySqlCommand(q, conn);
                    conn.Open();
                    var resultValue = comand.ExecuteReader();
                    if (!resultValue.HasRows)
                    {
                        conn.Close();

                        MySqlCommand command = conn.CreateCommand();

                        string code = txtType.Text;

                        int typecount = txtType.Text.Length;

                        int factorycount = txtFactory.Text.Length;

                        int groupcount = txtGroup.Text.Length;

                        int productcount = txtProduct.Text.Length;

                        while (typecount < 4)
                        {
                            code = "0" + code;
                            typecount++;
                        }

                        string code2 = txtFactory.Text;

                        while (factorycount < 4)
                        {
                            code2 = "0" + code2;
                            factorycount++;
                        }

                        code = code + code2;

                        string code3 = txtGroup.Text;

                        while (groupcount < 4)
                        {
                            code3 = "0" + code3;
                            groupcount++;
                        }

                        code = code + code3;

                        string code4 = txtProduct.Text;

                        while (productcount < 4)
                        {
                            code4 = "0" + code4;
                            productcount++;
                        }

                        code = code + code4;

                        string query2 = "SELECT count(Code) FROM data where Type_ID=" + txtType.Text + " and Factory_ID=" + txtFactory.Text + " and Group_ID=" + txtGroup.Text + " and Product_ID=" + txtProduct.Text;
                        conn.Open();
                        MySqlCommand adpt   = new MySqlCommand(query2, conn);
                        int          result = Convert.ToInt16(adpt.ExecuteScalar().ToString());
                        result = result + 1;
                        conn.Close();

                        int resultcount = result.ToString().Length;

                        string code5 = result.ToString();

                        while (resultcount < 4)
                        {
                            code5 = "0" + code5;
                            resultcount++;
                        }

                        code = code + code5;

                        command.CommandText = "INSERT INTO data (Color_ID,Size_ID,Sort_ID,Description,Carton,Code,Type_ID,Factory_ID,Group_ID,Product_ID,Classification,Data_Date) VALUES (?Color_ID,?Size_ID,?Sort_ID,?Description,?Carton,?Code,?Type_ID,?Factory_ID,?Group_ID,?Product_ID,?Classification,?Data_Date)";

                        command.Parameters.AddWithValue("?Color_ID", color_id);
                        command.Parameters.AddWithValue("?Size_ID", size_id);
                        command.Parameters.AddWithValue("?Sort_ID", sort_id);
                        command.Parameters.AddWithValue("?Description", description);
                        command.Parameters.AddWithValue("?Carton", carton);
                        command.Parameters.AddWithValue("?Code", code);
                        command.Parameters.AddWithValue("?Type_ID", int.Parse(txtType.Text));
                        command.Parameters.AddWithValue("?Factory_ID", int.Parse(txtFactory.Text));
                        command.Parameters.AddWithValue("?Group_ID", int.Parse(txtGroup.Text));
                        command.Parameters.AddWithValue("?Product_ID", int.Parse(txtProduct.Text));
                        command.Parameters.AddWithValue("?Classification", classification);
                        command.Parameters.AddWithValue("?Data_Date", DateTime.Now.Date);
                        conn.Open();
                        command.ExecuteNonQuery();

                        query2 = "select Data_ID from data order by Data_ID desc limit 1";
                        comand = new MySqlCommand(query2, conn);
                        int data_ID = Convert.ToInt16(comand.ExecuteScalar());
                        //save image as bytes
                        command = conn.CreateCommand();
                        if (selectedImage != null)
                        {
                            command.CommandText = "INSERT INTO data_photo (Data_ID,Photo,Type) VALUES (?Data_ID,?Photo,?Type)";
                            command.Parameters.AddWithValue("?Data_ID", data_ID);
                            command.Parameters.AddWithValue("?Photo", selectedImage);
                            command.Parameters.AddWithValue("?Type", "بند");
                            command.ExecuteNonQuery();
                        }

                        products.displayProducts();
                        UserControl.ItemRecord("data", "اضافة", data_ID, DateTime.Now, "", conn);
                        clear();
                        comType.Focus();
                    }
                    else
                    {
                        MessageBox.Show("This item already exist");
                    }
                }
                else
                {
                    MessageBox.Show("you should fill all fields");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            conn.Close();
        }