コード例 #1
0
ファイル: FormOrder.cs プロジェクト: Steelray17/MasterOK
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            OrderSet orderSet = new OrderSet();

            orderSet.idClient   = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
            orderSet.idEmployee = Convert.ToInt32(comboBoxEmployee.SelectedItem.ToString().Split('.')[0]);
            orderSet.idProduct  = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]);
            orderSet.Date       = textBoxDate.Text;

            Program.master.OrderSet.Add(orderSet);
            Program.master.SaveChanges();
            ShowOrderSet();
        }
コード例 #2
0
ファイル: FormOrder.cs プロジェクト: Steelray17/MasterOK
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewOrders.SelectedItems.Count == 1)
            {
                OrderSet orderSet = listViewOrders.SelectedItems[0].Tag as OrderSet;

                orderSet.idClient   = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                orderSet.idEmployee = Convert.ToInt32(comboBoxEmployee.SelectedItem.ToString().Split('.')[0]);
                orderSet.idProduct  = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]);
                orderSet.Date       = textBoxDate.Text;

                Program.master.SaveChanges();
                ShowOrderSet();
            }
        }
コード例 #3
0
ファイル: FormOrder.cs プロジェクト: Steelray17/MasterOK
        private void listViewOrders_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewOrders.SelectedItems.Count == 1)
            {
                OrderSet orderSet = listViewOrders.SelectedItems[0].Tag as OrderSet;

                comboBoxClient.SelectedIndex   = comboBoxClient.FindString(orderSet.idClient.ToString());
                comboBoxEmployee.SelectedIndex = comboBoxEmployee.FindString(orderSet.idEmployee.ToString());
                comboBoxProduct.SelectedIndex  = comboBoxProduct.FindString(orderSet.idProduct.ToString());
                textBoxDate.Text = orderSet.Date;
            }
            else
            {
                comboBoxClient.SelectedItem   = null;
                comboBoxEmployee.SelectedItem = null;
                comboBoxProduct.SelectedItem  = null;
                textBoxDate.Text = "";
            }
        }
コード例 #4
0
ファイル: FormOrder.cs プロジェクト: Steelray17/MasterOK
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewOrders.SelectedItems.Count == 1)
                {
                    OrderSet orderSet = listViewOrders.SelectedItems[0].Tag as OrderSet;
                    Program.master.OrderSet.Remove(orderSet);

                    Program.master.SaveChanges();
                    ShowOrderSet();
                }
                comboBoxClient.SelectedItem   = null;
                comboBoxEmployee.SelectedItem = null;
                comboBoxProduct.SelectedItem  = null;
                textBoxDate.Text = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }