using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data; using Stone.Entity; using Gm_WMS.DataAccess.DataService; using Stone.Common; namespace Stone.WinBiz.BasicData { public class F_Emp : F_Base { public F_Emp() { this.type = "Emp"; this.name = "基础资料_员工管理"; this.entity = new Entity_t_Emp(); this.entityView = new Entity_v_Emp(); } public override void GetView(DataGridView dgv) { base.GetView(dgv); dgv.Columns["DepCode"].HeaderText = "部门编号"; dgv.Columns["DepName"].HeaderText = "部门名称"; dgv.Columns["Code"].HeaderText = "编号"; dgv.Columns["Name"].HeaderText = "名称"; dgv.Columns["Memo"].HeaderText = "备注"; } public override void Checking(DataRow drData, bool isNew) { if (drData["Code"].ToString().Trim() == "") throw new Exception("编号 不能为空!"); if (drData["Code"].ToString().Trim().Length != 2) throw new Exception("编号 必需是2位!"); Entity_t_Dep t_Dep = new Entity_t_Dep(); if (t_Dep.GetData("[DepCode]='" + drData["DepCode"].ToString() + "'").Tables[0].Rows.Count == 0) throw new Exception("部门编号 " + drData["DepCode"].ToString() + " 在系统中不存在"); if (isNew) { if (entity.GetData("", "Code='" + drData["Code"].ToString() + "'", "id asc").Tables[0].Rows.Count > 0) throw new Exception("编号 " + drData["Code"].ToString() + " 已经存在!"); } else { if (entity.GetData("", "[ID]<>" + drData["ID"].ToString() + " and Code='" + drData["Code"].ToString() + "'", "id asc").Tables[0].Rows.Count > 0) throw new Exception("编号 " + drData["Code"].ToString() + " 已经存在!"); } } public override void InputData(DataSet dsData, LocalDBService db) { Entity_t_Emp t_Input = new Entity_t_Emp(db); Entity_t_Dep t_Dep = new Entity_t_Dep(db); DataRow drInput = null; foreach (DataRow drData in dsData.Tables[0].Rows) { drInput = t_Input.Table.NewRow(); drInput["DepCode"] = MyStrings.GetString(drData["部门编号"].ToString().Trim()); drInput["Code"] = MyStrings.GetString(drData["编号"].ToString().Trim()); drInput["Name"] = MyStrings.GetString(drData["名称"].ToString().Trim()); drInput["Memo"] = MyStrings.GetString(drData["备注"].ToString().Trim()); if (drInput["Code"].ToString().Trim() == "") throw new Exception("编号 不能为空!"); if (drInput["Code"].ToString().Trim().Length != 2) throw new Exception("编号 必需是2位!"); if (drInput["Name"].ToString().Trim() == "") throw new Exception("名称 不能为空!"); if (t_Dep.GetData("[Code]='" + drInput["DepCode"].ToString() + "'").Tables[0].Rows.Count == 0) throw new Exception("部门编号 " + drInput["DepCode"].ToString() + " 在系统中不存在"); if (t_Input.GetData("", "Code='" + drInput["Code"].ToString() + "'", "id asc").Tables[0].Rows.Count > 0) throw new Exception("编号 " + drInput["Code"].ToString() + " 已经存在!"); t_Input.Add(drInput); } } } }