//确定 private void okBtn_Click(object sender, EventArgs e) { if (catgory.Text == "") { GeneralClass.printErrorMsg("需要选择类别!"); return; } if (name.Text == "") { GeneralClass.printErrorMsg("需要输入名称!"); return; } if (unit.Text == "") { GeneralClass.printErrorMsg("需要输入单位!"); return; } m_menu.name = name.Text; m_menu.unit = unit.Text; m_menu.catgoryId = db.Catgory.FirstOrDefault(x => x.name == catgory.Text).id; m_menu.note = note.Text; m_menu.addAutomatic = addAutomatic.Checked; m_menu.waiter = waiter.Checked; m_menu.technician = technician.Checked; if (technician.Checked) { m_menu.techRatioType = techRatioType.Text; if (onRatio.Text == "" || orderRatio.Text == "") { GeneralClass.printErrorMsg("需要输入提成比例!"); return; } m_menu.techRatioCat = techRatioCat.Text; m_menu.onRatio = Convert.ToDouble(onRatio.Text); m_menu.orderRatio = Convert.ToDouble(orderRatio.Text); } if (waiter.Checked) { if (waiterRatio.Text == "") { GeneralClass.printErrorMsg("需要输入提成比例!"); return; } m_menu.waiterRatioType = waiterRatioType.SelectedIndex; m_menu.waiterRatio = Convert.ToDouble(waiterRatio.Text); } if (price.Text == "") { price.Focus(); GeneralClass.printErrorMsg("需要输入价格!"); return; } m_menu.price = Convert.ToDouble(price.Text); //if (timeLimitHour.Text == "" || timeLimitMiniute.Text == "") //{ // GeneralClass.printErrorMsg("需要输入数据!"); // return; //} if (addAutomatic.Checked) { if (addType.Text == "") { GeneralClass.printErrorMsg("需要选择添加类型!"); return; } m_menu.timeLimitType = timeLimitType.Text; m_menu.addType = addType.Text; m_menu.timeLimitHour = Convert.ToInt32(timeLimitHour.Text); m_menu.timeLimitMiniute = Convert.ToInt32(timeLimitMiniute.Text); if (addType.SelectedIndex == 1) { if (addMoney.Text == "") { GeneralClass.printErrorMsg("需要输入价格!"); return; } m_menu.addMoney = Convert.ToDouble(addMoney.Text); } } if (dgv.Rows.Count != 0) { m_menu.ResourceExpense = BathClass.assemble_Menu_resourceExpense(resourceExpense); } if (db.Unit.FirstOrDefault(x => x.name == unit.Text) == null) { Unit newUnit = new Unit(); newUnit.name = unit.Text; db.Unit.InsertOnSubmit(newUnit); } if (newMenu) { db.Menu.InsertOnSubmit(m_menu); db.SubmitChanges(); m_Form.dgv_show(); name.Text = ""; catgory.Text = m_cat; price.Text = ""; technician.Checked = false; techRatioType.SelectedIndex = 0; onRatio.Text = ""; orderRatio.Text = ""; timeLimitHour.Text = "0"; timeLimitMiniute.Text = "0"; addAutomatic.Checked = false; addType.Text = ""; addType.Enabled = false; addMoney.Text = "10"; addMoney.Enabled = false; note.Text = ""; m_menu = new YouSoftBathGeneralClass.Menu(); name.Focus(); dgv.Rows.Clear(); return; } else { db.SubmitChanges(); this.DialogResult = DialogResult.OK; } }