public void GetDeptItem() { string _id = Parameters["pid"]; SysDepartment item = new SysDepartment(); SysDepartmentBiz biz = new SysDepartmentBiz(); item = biz.Select(_id); if (item == null) { Response.Write(""); } else { Response.Write(item.ToJson()); } }
public Int64 Insert(SysDepartment item, out ErrorEntity ErrInfo) { if (string.IsNullOrEmpty(item.FDepartmentName)) { ErrInfo = new ErrorEntity("DM010001", "部门名称不能为空!"); return -1; } if (string.IsNullOrEmpty(item.FDepartmentCode)) { ErrInfo = new ErrorEntity("DM010002", "部门编号不能为空!"); return -1; } if (!ChkDeptCode(item.FDepartmentID.ToString(), item.FDepartmentCode)) { ErrInfo = new ErrorEntity("DM010003", "部门编号已经存在,不能重复!"); return -1; } if (!ChkDeptName(item.FDepartmentID.ToString(), item.FDepartmentName)) { ErrInfo = new ErrorEntity("DM010004", "部门名称已经存在,不能重复!"); return -1; } if(item.FDepartmentTypeId == 0) { ErrInfo = new ErrorEntity("DM010005","部门归属不能为空!"); return -1; } NameValueCollection parameters = new NameValueCollection(); parameters.Add("FDepartmentTypeId", item.FDepartmentTypeId.ToString()); parameters.Add("FDepartmentCode", item.FDepartmentCode); parameters.Add("FDepartmentName", item.FDepartmentName); parameters.Add("FDepartmentCharge", item.FDepartmentCharge); if (item.FDepartmentNum > 1) { parameters.Add("FDepartmentNum", item.FDepartmentNum.ToString()); } parameters.Add("FDepartmentTel", item.FDepartmentTel); parameters.Add("FDepartmentContent", item.FDepartmentContent); return Insert(parameters, out ErrInfo); }
public void SaveItem() { string _deptid = Parameters["pdeptid"]; string _deptcode = Parameters["pdeptcode"]; string _depttype = Parameters["pdepttype"]; string _deptname = Parameters["pdeptname"]; string _deptcharge = Parameters["pdeptcharge"]; string _depttel = Parameters["pdepttel"]; string _deptnum = Parameters["pdeptnum"]; string _content = Parameters["pcontent"]; SysDepartment item = new SysDepartment(); item.FDepartmentID = string.IsNullOrEmpty(_deptid) ? 0 : Convert.ToInt64(_deptid); item.FDepartmentCode = _deptcode; item.FDepartmentName = _deptname; item.FDepartmentCharge = _deptcharge; item.FDepartmentTypeId = string.IsNullOrEmpty(_depttype) ? 0 : Convert.ToInt64(_depttype); item.FDepartmentContent = _content; item.FDepartmentTel = _depttel; item.FDepartmentNum = string.IsNullOrEmpty(_deptnum) ? 0 : Convert.ToInt32(_deptnum); SysDepartmentBiz biz = new SysDepartmentBiz(); ErrorEntity ErrInfo = new ErrorEntity(); if (item.FDepartmentID == 0) { biz.Insert(item, out ErrInfo); } else { biz.Update(item, out ErrInfo); } Response.Write(ErrInfo.ToJson()); }