예제 #1
0
        private void gridControl1_Click(object sender, EventArgs e)
        {
            DataRowView CurrentRow = StoreGridView1.GetFocusedRow() as DataRowView;

            CurrentPositionTextBox.Text = CurrentRow["position"].ToString();

            CurrentQuantityTextBox.ReadOnly = false;

            ChangePositionButton.Enabled = isAdmin;
            DeletePositionButton.Enabled = isAdmin;

            CurrentQuantityTextBox.Text = "";
        }
예제 #2
0
        private void DeletePositionButton_Click(object sender, EventArgs e)
        {
            DataRowView CurrentRow        = StoreGridView1.GetFocusedRow() as DataRowView;
            int         CurrentId         = Int32.Parse(CurrentRow["id"].ToString());
            string      CurrentQuantity   = CurrentRow["quantity"].ToString();
            string      CurrentPrice      = CurrentRow["price"].ToString();
            string      CurrentFirstPrice = CurrentRow["first_price"].ToString();
            string      CurrentPosition   = CurrentRow["position"].ToString();

            ManageForm manage_form = new ManageForm(CurrentId, CurrentPosition, CurrentQuantity, CurrentPrice, CurrentFirstPrice, (int)OperationType.Delete);

            manage_form.ShowDialog();
            manage_form.Close();
            UpdateGrids();
        }
예제 #3
0
        private void ExecuteOperation(int OpType, string OperationTypeName)
        {
            DataRowView CurrentRow     = StoreGridView1.GetFocusedRow() as DataRowView;
            int         op_id          = Int32.Parse(CurrentRow["id"].ToString());
            int         op_quantity    = Int32.Parse(CurrentQuantityTextBox.Text);
            int         op_price       = Int32.Parse(CurrentRow["price"].ToString());
            int         op_first_price = Int32.Parse(CurrentRow["first_price"].ToString());
            string      op_position    = CurrentRow["position"].ToString();



            using (SqlConnection StoreCon = new SqlConnection(Connection))
            {
                string StoreProc   = @"sale";
                string StoreProc_2 = @"InsertTableOperations";

                StoreCon.Open();
                SqlTransaction sqlTran = StoreCon.BeginTransaction(); /*Начало транзакции*/
                SqlCommand     ComSql  = new SqlCommand(StoreProc, StoreCon);
                ComSql.Transaction = sqlTran;                         /*добавляем операцию в транзакцию*/
                SqlCommand ComSql_2 = new SqlCommand(StoreProc_2, StoreCon);
                ComSql_2.Transaction = sqlTran;                       /*добавляем операцию в транзакцию*/

                try
                {
                    ComSql.CommandType = CommandType.StoredProcedure;
                    ComSql.Parameters.AddWithValue("@op_type", OpType);
                    ComSql.Parameters.AddWithValue("@op_id", op_id);
                    ComSql.Parameters.AddWithValue("@op_quantity", op_quantity);
                    ComSql.Parameters.AddWithValue("@op_price", op_price);
                    ComSql.ExecuteNonQuery();



                    ComSql_2.CommandType = CommandType.StoredProcedure;
                    ComSql_2.Parameters.AddWithValue("@position_id", op_id);
                    ComSql_2.Parameters.AddWithValue("@operation_type", OperationTypeName);
                    ComSql_2.Parameters.AddWithValue("@position", op_position);
                    ComSql_2.Parameters.AddWithValue("@quantity", op_quantity);
                    ComSql_2.Parameters.AddWithValue("@price", op_price);
                    ComSql_2.Parameters.AddWithValue("@first_price", op_first_price);
                    ComSql_2.ExecuteNonQuery();

                    sqlTran.Commit();

                    Logger.LogText += OperationTypeName + "\r\n ID " + op_id + "\r\n Товар " + op_position +
                                      "\r\n Количество " + op_quantity + "\r\n Цена " + op_price
                                      + "\r\n Сумма " + op_price * op_quantity + "\r\n закупочная цена "
                                      + op_first_price + "\r\n Пользователь " + UserLabel.Text + "\r\n";
                }
                catch (Exception e)
                {
                    sqlTran.Rollback();
                    MessageBox.Show(e.Message);
                    Logger.LogText += OperationTypeName + " Ошибка " + e.Message + "\r\n ID " + op_id + "\r\n Товар " + op_position +
                                      "\r\n Количество " + op_quantity + "\r\n Цена " + op_price
                                      + "\r\n Сумма " + op_price * op_quantity + "\r\n закупочная цена "
                                      + op_first_price;
                }
                finally
                {
                    Logger.LogWrite(Logger.LogText);
                }
            }
        }