Ejemplo n.º 1
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (Qds_CardTypesDataGridView.Rows.Count < 1)
            {
                return;
            }

            if (OK.Text == "&Select")
            {
                try
                {
                    containerId = (int)this.Qds_CardTypesDataGridView.CurrentRow.Cells[0].Value;
                    if (containerId < 1)
                    {
                        throw new Exception();
                    }
                    containerName = Qds_CardTypesDataGridView.CurrentRow.Cells[1].Value.ToString().Trim();
                }
                catch
                {
                    MessageBox.Show("Please select a valid customer.");
                    return;
                }

                Close();
                return;
            }


            BindingNavigatorSaveItem.PerformClick();
        }
Ejemplo n.º 2
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (DataGridView1.Rows.Count < 1)
            {
                return;
            }

            if (OK.Text == "&Select")
            {
                try
                {
                    fieldId = (int)this.DataGridView1.CurrentRow.Cells[0].Value;
                    if (fieldId < 1)
                    {
                        throw new Exception();
                    }
                    fieldName = DataGridView1.CurrentRow.Cells[1].Value.ToString().Trim();
                }
                catch
                {
                    MessageBox.Show("Please select a valid item.");
                    return;
                }

                Close();
                return;
            }


            BindingNavigatorSaveItem.PerformClick();
        }
Ejemplo n.º 3
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (DataGridView1.Rows.Count < 1)
            {
                return;
            }

            int paymentMethodID = (int)DataGridView1.CurrentRow.Cells[1].Value;

            if (paymentMethodID == 0)
            {
                MessageBox.Show("Please select another method!");
                return;
            }

            //Check that PaymentMethod is not assigned if change
            if (formerPaymentMethodID != paymentMethodID)
            {
                if (qds_PaymentMethodAvailableByDepot_Sp == null)
                {
                    qds_PaymentMethodAvailableByDepot_Sp = new Qds_PaymentMethodAvailableByDepot_Sp(Properties.Settings.Default.WsirDbConnectionString);
                }

                qds_PaymentMethodAvailableByDepot = qds_PaymentMethodAvailableByDepot_Sp.Select(depotID, paymentMethodID);

                if (qds_PaymentMethodAvailableByDepot != null)
                {
                    MessageBox.Show("Payment Method already assigned!");
                    return;
                }
            }

            //only on DepotDefault
            bool depotDefault = (bool)DataGridView1.CurrentRow.Cells[2].Value;

            if (depotDefault &&
                (formerDepotDefault != depotDefault))
            {
                using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.WsirDbConnectionString))
                {
                    try
                    {
                        string query =
                            "UPDATE [Qds_PaymentMethodAvailableByDepot] WITH (ROWLOCK) " +
                            "SET [DepotDefault] = 0 " +
                            "WHERE [DepotID] = '" + depotID + "' ";
                        using (SqlCommand command = new SqlCommand(query, connection))
                        {
                            connection.Open();
                            command.ExecuteNonQuery();
                        }
                    }
                    catch
                    {
                        //
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
            }

            if (OK.Text == "&Select")
            {
                try
                {
                    int.TryParse(this.DataGridView1.CurrentRow.Cells[0].Value.ToString(), out fieldId);
                    if (fieldId < 1)
                    {
                        throw new Exception();
                    }
                    fieldName = DataGridView1.CurrentRow.Cells[1].Value.ToString().Trim();
                }
                catch
                {
                    MessageBox.Show("Please select a valid item.");
                    return;
                }

                Close();
                return;
            }


            BindingNavigatorSaveItem.PerformClick();
        }