/// <summary> /// 编辑组织机构信息 /// </summary> /// <param name="model">保存信息</param> /// <returns></returns> public static bool SaveDeptInfo(DeptModel model) { //获取登陆用户信息 UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; //设置公司代码 model.CompanyCD = userInfo.CompanyCD; model.ModifiedUserID = userInfo.UserID; //定义返回变量 bool isSucc = false; //操作日志 LogInfoModel logModel = InitLogInfo(model.DeptNO); //更新 if (ConstUtil.EDIT_FLAG_UPDATE.Equals(model.EditFlag)) { try { logModel.Element = ConstUtil.LOG_PROCESS_UPDATE; //执行更新操作 isSucc = DeptInfoDBHelper.UpdateDeptInfo(model); } catch (Exception ex) { //输出系统日志 WriteSystemLog(userInfo, ex); } } //插入 else { try { logModel.Element = ConstUtil.LOG_PROCESS_INSERT; //执行插入操作 isSucc = DeptInfoDBHelper.InsertDeptInfo(model); } catch (Exception ex) { //输出系统日志 WriteSystemLog(userInfo, ex); } } //更新成功时 if (isSucc) { //设置操作成功标识 logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS; } //更新不成功 else { //设置操作成功标识 logModel.Remark = ConstUtil.LOG_PROCESS_FAILED; } //登陆日志 LogDBHelper.InsertLog(logModel); return isSucc; }
/// <summary> /// 添加组织机构信息 /// </summary> /// <param name="model">组织机构信息</param> /// <returns></returns> public static bool InsertDeptInfo(DeptModel model) { #region 插入SQL拼写 StringBuilder insertSql = new StringBuilder(); insertSql.AppendLine(" INSERT INTO officedba.DeptInfo "); insertSql.AppendLine(" (CompanyCD "); insertSql.AppendLine(" ,DeptNO "); insertSql.AppendLine(" ,SuperDeptID "); insertSql.AppendLine(" ,PYShort "); insertSql.AppendLine(" ,DeptName "); insertSql.AppendLine(" ,AccountFlag "); insertSql.AppendLine(" ,SaleFlag "); insertSql.AppendLine(" ,SubFlag "); insertSql.AppendLine(" ,Address "); insertSql.AppendLine(" ,Post "); insertSql.AppendLine(" ,LinkMan "); insertSql.AppendLine(" ,Tel "); insertSql.AppendLine(" ,Fax "); insertSql.AppendLine(" ,Email "); insertSql.AppendLine(" ,Duty "); insertSql.AppendLine(" ,UsedStatus "); insertSql.AppendLine(" ,Description "); insertSql.AppendLine(" ,ModifiedDate "); insertSql.AppendLine(" ,ModifiedUserID) "); insertSql.AppendLine(" VALUES "); insertSql.AppendLine(" (@CompanyCD "); insertSql.AppendLine(" ,@DeptNO "); insertSql.AppendLine(" ,@SuperDeptID "); insertSql.AppendLine(" ,@PYShort "); insertSql.AppendLine(" ,@DeptName "); insertSql.AppendLine(" ,@AccountFlag "); insertSql.AppendLine(" ,@SaleFlag "); insertSql.AppendLine(" ,@SubFlag "); insertSql.AppendLine(" ,@Address "); insertSql.AppendLine(" ,@Post "); insertSql.AppendLine(" ,@LinkMan "); insertSql.AppendLine(" ,@Tel "); insertSql.AppendLine(" ,@Fax "); insertSql.AppendLine(" ,@Email "); insertSql.AppendLine(" ,@Duty "); insertSql.AppendLine(" ,@UsedStatus "); insertSql.AppendLine(" ,@Description "); insertSql.AppendLine(" ,getdate() "); insertSql.AppendLine(" ,@ModifiedUserID) "); #endregion //定义插入基本信息的命令 SqlCommand comm = new SqlCommand(); comm.CommandText = insertSql.ToString(); //设置保存的参数 SetSaveParameter(comm, model); //执行插入操作并返回更新结果 return SqlHelper.ExecuteTransWithCommand(comm); }
protected void BindSubStore() { XBase.Model.Office.HumanManager.DeptModel model = new XBase.Model.Office.HumanManager.DeptModel(); model.CompanyCD = UserInfo.CompanyCD; DataTable dtSource = XBase.Business.Office.LogisticsDistributionManager.SubProductSendPriceBus.GetSubStore(model); ddlSubStore.DataSource = dtSource; ddlSubStore.DataTextField = "DeptName"; ddlSubStore.DataValueField = "ID"; ddlSubStore.DataBind(); ddlSubStore.Items.Insert(0,new ListItem("--请选择--", "-1")); }
protected void BindSubStore() { XBase.Model.Office.HumanManager.DeptModel model = new XBase.Model.Office.HumanManager.DeptModel(); model.CompanyCD = UserInfo.CompanyCD; DataTable dtSource = XBase.Business.Office.LogisticsDistributionManager.SubProductSendPriceBus.GetSubStore(model); ddlSubStore.DataSource = dtSource; ddlSubStore.DataTextField = "DeptName"; ddlSubStore.DataValueField = "ID"; ddlSubStore.DataBind(); ddlSubStore.Items.Insert(0, new ListItem("--请选择--", "-1")); }
/// <summary> /// 保存时基本信息参数设置 /// </summary> /// <param name="comm">命令</param> /// <param name="model">保存信息</param> private static void SetSaveParameter(SqlCommand comm, DeptModel model) { //设置参数 comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD",model.CompanyCD));//公司代码 comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptNO", model.DeptNO));//机构编号 //插入时,设置上级机构ID if (ConstUtil.EDIT_FLAG_INSERT.Equals(model.EditFlag)) { } comm.Parameters.Add(SqlHelper.GetParameterFromString("@SuperDeptID", model.SuperDeptID));//上级机构ID(对应本表的ID) comm.Parameters.Add(SqlHelper.GetParameterFromString("@PYShort", model.PYShort));//机构拼音代码 comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptName", model.DeptName));//机构名称 comm.Parameters.Add(SqlHelper.GetParameterFromString("@AccountFlag", model.AccountFlag));//是否独立核算(0否,1是) comm.Parameters.Add(SqlHelper.GetParameterFromString("@SaleFlag", model.SaleFlag));//是否为零售店(0否,1是) comm.Parameters.Add(SqlHelper.GetParameterFromString("@SubFlag", model.SubFlag));//是否为分公司(0否,1是) comm.Parameters.Add(SqlHelper.GetParameterFromString("@Address", model.Address));//地址 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Post", model.Post));//邮编 comm.Parameters.Add(SqlHelper.GetParameterFromString("@LinkMan", model.LinkMan));//联系人 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Tel", model.Tel));//电话 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Fax", model.Fax));//传真 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Email", model.Email));//Email comm.Parameters.Add(SqlHelper.GetParameterFromString("@Duty", model.Duty));//职责 comm.Parameters.Add(SqlHelper.GetParameterFromString("@UsedStatus", model.UsedStatus));//启用状态(0停用,1启用) comm.Parameters.Add(SqlHelper.GetParameterFromString("@Description", model.Description));//描述 comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", model.ModifiedUserID));//最后更新用户ID }
/// <summary> /// 更新组织机构信息 /// </summary> /// <param name="model">保存信息</param> /// <returns></returns> public static bool UpdateDeptInfo(DeptModel model) { #region 更新SQL拼写 StringBuilder updateSql = new StringBuilder(); updateSql.AppendLine(" UPDATE officedba.DeptInfo "); updateSql.AppendLine(" SET "); updateSql.AppendLine(" PYShort = @PYShort "); updateSql.AppendLine(" ,DeptName = @DeptName "); updateSql.AppendLine(" ,AccountFlag = @AccountFlag "); updateSql.AppendLine(" ,SaleFlag = @SaleFlag "); updateSql.AppendLine(" ,SubFlag = @SubFlag "); updateSql.AppendLine(" ,Address = @Address "); updateSql.AppendLine(" ,Post = @Post "); updateSql.AppendLine(" ,LinkMan = @LinkMan "); updateSql.AppendLine(" ,Tel = @Tel "); updateSql.AppendLine(" ,Fax = @Fax "); updateSql.AppendLine(" ,Email = @Email "); updateSql.AppendLine(" ,Duty = @Duty ,SuperDeptID=@SuperDeptID "); updateSql.AppendLine(" ,UsedStatus = @UsedStatus "); updateSql.AppendLine(" ,Description = @Description "); updateSql.AppendLine(" ,ModifiedDate = getdate() "); updateSql.AppendLine(" ,ModifiedUserID = @ModifiedUserID "); updateSql.AppendLine(" WHERE "); updateSql.AppendLine(" CompanyCD = @CompanyCD "); updateSql.AppendLine(" AND DeptNO = @DeptNO "); #endregion //定义更新基本信息的命令 SqlCommand comm = new SqlCommand(); comm.CommandText = updateSql.ToString(); //设置保存的参数 SetSaveParameter(comm, model); //执行插入操作并返回更新结果 return SqlHelper.ExecuteTransWithCommand(comm); }