private void btn_Modify_Click(object sender, RoutedEventArgs e)
        {
            ValuePrice modifiedPrice = new ValuePrice();

            try
            {
                modifiedPrice.Unit_Price = double.Parse(txt_Price.Text);
            }
            catch
            {
                SystemSounds.Beep.Play();
                MessageBox.Show("工序单价必须为数字!");
                return;
            }
            modifiedPrice.Id           = OriginPrice.Id;
            modifiedPrice.Procedure_Id = OriginPrice.Procedure_Id;
            modifiedPrice.Value_Id     = OriginPrice.Value_Id;
            modifiedPrice.Unit         = txt_Unit.Text;
            Db.UpdatePrice(modifiedPrice);
            PsPage.FillPrice();
            this.Close();
        }
Beispiel #2
0
        private void btn_AddRelationship_Click(object sender, RoutedEventArgs e)
        {
            Assign a = new Assign();

            a.EmployeeId = (cmb_Employee.SelectedItem as Employee).Id;
            a.Price_Id   = SelectedPrice.Id;
            if (Db.QueryAssignWhetherExsit(a).Count() > 0)
            {
                SystemSounds.Beep.Play();
                string str = "该员工已被分配到此工序!";
                MessageBox.Show(str);
                return;
            }
            Db.InsertAssign(a);
            Assign a0 = Db.QueryAssignWhetherExsit(a).Single();
            Reckon r  = new Reckon();

            r.Assign_Id = a0.Id;
            r.Count     = 0;
            Db.InsertReckon(r);
            PsPage.FillEmployee();
            this.Close();
        }
        private void btn_AddTask_Click(object sender, RoutedEventArgs e)
        {
            Value v = new Value();

            if (cmb_Product.SelectedIndex == -1)
            {
                SystemSounds.Beep.Play();
                MessageBox.Show("产品编号不能为空!");
                return;
            }
            else
            {
                v.Product_Id   = (cmb_Product.SelectedItem as Product).Id;
                v.Product_Name = (cmb_Product.SelectedItem as Product).Name;
            }
            try
            {
                if (string.IsNullOrWhiteSpace(txt_TaskNum.Text) == true)
                {
                    SystemSounds.Beep.Play();
                    MessageBox.Show("任务编号不能为空!");
                    return;
                }
                else
                {
                    v.TaskNum = int.Parse(txt_TaskNum.Text);
                }
            }
            catch (FormatException fe)
            {
                txt_TaskNum.Text = string.Empty;
                SystemSounds.Beep.Play();
                MessageBox.Show("任务编号必须为数字!");
                return;
            }
            //if (Db.QueryValueByName(txt_Value.Text).Count() == 0)
            // QueryValueByNameNotInProduct
            if (Db.QueryValueByNameAndProductId(txt_Value.Text, v.Product_Id).Count() == 0)
            {
                v.Name = txt_Value.Text;
            }
            else
            {
                SystemSounds.Beep.Play();
                MessageBox.Show("该产品已存在感值:" + txt_Value.Text);
                txt_Value.Text = string.Empty;
                return;
            }
            v.TaskDate = DateTime.Now;
            Db.InsertValue(v);
            IEnumerable <Relationship> relateList = Db.QueryRelationshipByProduct_Id(v.Product_Id);

            foreach (Relationship item in relateList)
            {
                ValuePrice price = new ValuePrice();
                price.Procedure_Id = Db.QueryProcedureByName(item.InputProcedure).Single().Id;
                price.Value_Id     = Db.QueryValueByTaskNum(v.TaskNum).Single().Id;
                Db.InsertValuePrice(price);
            }
            PsPage.FillGridTask();
            this.Close();
        }