Пример #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            Row = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[1].FormattedValue);
            this.Hide();
            AddBuyingInvoice BuyInvoice = new AddBuyingInvoice();

            BuyInvoice.fromAnotherForm       = 1;
            BuyInvoice.Com_Suppliers.Enabled = false;
            BuyInvoice.ComboSelected         = Row - 1;
            BuyInvoice.ShowDialog();
        }
Пример #2
0
        private void But_AddInvoice_Click(object sender, EventArgs e)
        {
            int found = 0;

            for (int i = 0; i < DrugUnitValue.Count; i++)
            {
                for (int m = 0; m < DrugUnitValue.Count; m++)
                {
                    if (DrugUnitValue[i] == DrugUnitValue[m])
                    {
                        found++;
                    }
                }
            }

            if (found <= DrugUnitValue.Count)

            {
                serial = ConnectionClass.SerialNumber();
                OutParameter.Direction = ParameterDirection.ReturnValue;
                ConnectionClass.Parameters(new SqlParameter("@supplierId", Com_Suppliers.SelectedValue), new SqlParameter("@invoiceDate", Convert.ToDateTime(dateTimePicker1.Text)), new SqlParameter("@InvAutoNumber", serial), OutParameter);
                ConnectionClass.SQLCommand("Cproc_AddBuyInvoice", CommandType.StoredProcedure, ExecuteReaderOrNonQuery.executeNonQuery);
                int x = (int)OutParameter.Value;
                for (int i = 0; i < PriceValueList.Count; i++)
                {
                    int      x1       = int.Parse(DrugUnitValue[i]);
                    decimal  price    = Convert.ToDecimal(PriceValueList[i]);
                    int      quantity = int.Parse(QntyValueList[i]);
                    DateTime D        = DatevalueList[i];
                    ConnectionClass.Parameters(new SqlParameter("@InvoiceId", x), new SqlParameter("@DrugId", x1), new SqlParameter("@pricePerUnit", price), new SqlParameter("@Qnty", quantity), new SqlParameter("@Expdate", D));
                    ConnectionClass.SQLCommand("AddInvoiceDetail", CommandType.StoredProcedure, ExecuteReaderOrNonQuery.executeNonQuery);
                    ConnectionClass.SQLCommandWithoutParameters("update pharmacy.drugs set Balance += " + quantity + " where DrugId= " + x1 + "", CommandType.Text, ExecuteReaderOrNonQuery.executeNonQuery);
                }

                var result = MessageBox.Show("تم اضافة الفاتورة بنجاح، هل تريد إضافة فاتورة أخرى", "إضافة أم خروج", MessageBoxButtons.YesNo);
                if (result == System.Windows.Forms.DialogResult.No)
                {
                    this.Close();
                    ConnectionClass.ParameterList.Clear();
                }
                else
                {
                    DrugUnitValue.Clear();
                    PriceValueList.Clear();
                    QntyValueList.Clear();
                    DatevalueList.Clear();
                    LblValue.Clear();

                    DrugUnitList.Clear();
                    PriceTextboxList.Clear();
                    QntyTextboxList.Clear();
                    ExpDatList.Clear();
                    LblList.Clear();

                    this.Close();
                    this.Dispose();
                    ConnectionClass.ParameterList.Clear();

                    AddBuyingInvoice Buy = new AddBuyingInvoice();
                    Buy.ShowDialog();
                }
            }
            else
            {
                But_Save.Enabled = true;
                for (int N = 15; N < Controls.Count; N++)
                {
                    Controls[N].Enabled = true;
                }
                MessageBox.Show("هناك عنصر مكرر بالفاتورة");
                DrugUnitValue.Clear();
                PriceValueList.Clear();
                QntyValueList.Clear();
                DatevalueList.Clear();

                sum = 0;
                But_AddInvoice.Visible = false;
            }
        }