public static WHArea Row2Entity(DataRow row) { if (row == null) { return(null); } WHArea area = new WHArea(); area.AreaCode = Cast.String(row["AreaCode"]); area.LocationCode = Cast.String(row["LocationCode"]); area.ParentArea = Cast.String(row["ParentArea"]); area.Name = Cast.String(row["Name"]); area.Text = Cast.String(row["Text"]); area.Status = Cast.Enum <WHStatus>(row["Status"], WHStatus.Disable); area.AreaCapacity = Cast.Decimal(row["AreaCapacity"], 99999999M); area.HasSection = Cast.Bool(row["HasSection"], true); area.IsQC = Cast.Bool(row["IsQC"], false); area.IsNonFormal = Cast.Bool(row["IsNonFormal"], false); area.IsScrap = Cast.Bool(row["IsScrap"], false); area.IsTransArea = Cast.Bool(row["IsTransArea"], false); area.IsReservedArea = Cast.Bool(row["IsReservedArea"], false); area.AllowDelete = Cast.Bool(row["AllowDelete"], false); area.AllowChild = Cast.Bool(row["AllowChild"], false); area.UseFixCost = Cast.Bool(row["UseFixCost"], false); area.CostFixValue = Cast.Decimal(row["CostFixValue"], 0M); area.CostTransRate = Cast.Decimal(row["CostTransRate"], 1M); area.FixedComsumeValue = Cast.Decimal(row["FixedComsumeValue"], 0M); return(area); }
public string FormatPaidText(object val) { if (val == null || val is DBNull) { return("否"); } bool paid = Cast.Bool(val, false); return(paid ? "是" : "否"); }
//Save Data private void SaveData() { MsgSubscriber msgSubscriber = new MsgSubscriber(); bool flag = true; try { msgSubscriber.TmplCode = Cast.String(txtTmplCode.Text.Trim()); msgSubscriber.UserId = Cast.Int(txtUserId.Text.Trim()); msgSubscriber.GroupId = Cast.Int(txtGroupId.Text.Trim()); msgSubscriber.IsGroup = Cast.Bool(txtIsGroup.Text.Trim()); msgSubscriber.SubscribeTime = Cast.DateTime(txtSubscribeTime.Text.Trim()); using (_session = new Session()) { if (IsAddNew()) { flag = msgSubscriber.Create(_session); } else { msgSubscriber.SubscriberId = int.Parse(this.txtSubscriberId.Value); flag = msgSubscriber.Update(_session, "TmplCode", "UserId", "GroupId", "IsGroup", "SubscribeTime"); } } this.txtSubscriberId.Value = msgSubscriber.SubscriberId.ToString(); if (flag) { WebUtil.ShowMsg(this, "操作成功", "提示"); } else { WebUtil.ShowMsg(this, "操作失败", "提示"); } } catch (UnauthorizedException ex) { WebUtil.ShowMsg(this, ex.Message, "警告"); } catch (ApplicationException ex) { WebUtil.ShowMsg(this, ex.Message, "提示"); } catch (Exception ex) { logger.Info("保存MsgSubscriber", ex); WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员"); } }
/// <summary> /// Map a DataRow to a District Entity. /// </summary> /// <returns></returns> public static District Row2Entity(System.Data.DataRow row) { if (row == null) { return(null); } District entity = new District(); entity._districtId = Cast.Int(row["DST_ID"]); entity._cityId = Cast.Int(row["CITY_ID"]); entity._zipCode = Cast.String(row["DST_ZIPCODE"]); entity._name = Cast.String(row["DST_NAME"]); entity._door2Door = Cast.Bool(row["DST_SHIP_TO"]); return(entity); }
/// <summary> /// Map a DataRow to a MsgSubscriber Entity. /// </summary> /// <returns></returns> public static MsgSubscriber Row2Entity(System.Data.DataRow row) { if (row == null) { return(null); } MsgSubscriber entity = new MsgSubscriber(); entity._subscriberId = Cast.Int(row["MSG_SUB_ID"]); entity._tmplCode = Cast.String(row["MSG_TMPL_CODE"]); entity._userId = Cast.Int(row["USR_ID"]); entity._groupId = Cast.Int(row["UGP_ID"]); entity._isGroup = Cast.Bool(row["IS_GROUP"]); entity._subscribeTime = Cast.DateTime(row["MSG_SUB_TIME"]); return(entity); }
public static string FormatEnableDisable(object value) { if (value == null || value == DBNull.Value) { return(""); } switch (value.ToString().ToLower()) { case "enable": return("启用"); case "disable": return("禁用"); } switch (Cast.Bool(value)) { case true: return("启用"); case false: return("禁用"); } return(""); }
/// <summary> /// Map a DataRow to a DictionaryItem Entity. /// </summary> /// <returns></returns> public static DictionaryItem Row2Entity(System.Data.DataRow row) { if (row == null) { return(null); } DictionaryItem entity = new DictionaryItem(); entity._itemCode = Cast.String(row["DIC_ITEM_CODE"]); entity._groupCode = Cast.String(row["DIC_GROUP"]); entity._name = Cast.String(row["DIC_NAME"]); entity._itemType = Cast.Enum <DictionaryItemType>(row["DIC_ITEM_TYPE"]); entity._boolValue = Cast.Bool(row["BOOL_VALUE"]); entity._numberValue = Cast.Decimal(row["NUMBER_VALUE"]); entity._stringValue = Cast.String(row["STRING_VALUE"]); entity._note = Cast.String(row["DIC_NOTE"]); return(entity); }
/// <summary> /// Map a DataRow to a MsgReceiver Entity. /// </summary> /// <returns></returns> public static MsgReceiver Row2Entity(System.Data.DataRow row) { if (row == null) { return(null); } MsgReceiver entity = new MsgReceiver(); entity._receiverId = Cast.Int(row["MSG_RCV_ID"]); entity._messageId = Cast.Int(row["MSG_ID"]); entity._userId = Cast.Int(row["USR_ID"]); entity._subscriberType = Cast.Bool(row["MSG_RCV_TYPE"]); entity._sendTime = Cast.DateTime(row["MSG_RCV_SEND_TIME"]); entity._receiveTime = Cast.DateTime(row["MSG_RCV_TIME"]); entity._expireTime = Cast.DateTime(row["MSG_RCV_EXPIRE_TIME"]); entity._readStatus = Cast.Enum <MessageReadStatus>(row["MSG_RCV_STATUS"]); entity._note = Cast.String(row["MSG_RCV_NOTE"]); return(entity); }
/// <summary> /// 以控件ID为Key取出参数值,使用默认值为: /// Boolean:false, String:string.emty /// </summary> /// <param name="ctrl"></param> public void SetValue(Control control) { bool cannotHandle = false; if (control != null) { string name = control.ID; string value = Pop(name); if (control is HtmlControl) //HtmlControls { if (control is HtmlInputControl) { if (control is HtmlInputCheckBox) { ((HtmlInputCheckBox)control).Checked = Magic.Framework.Utils.Cast.Bool(value); } else if (control is HtmlInputRadioButton) { ((HtmlInputCheckBox)control).Checked = Magic.Framework.Utils.Cast.Bool(value); } else if (control is HtmlInputImage) { ((HtmlInputImage)control).Src = value; } else { ((HtmlInputControl)control).Value = value; } } else if (control is HtmlContainerControl) { if (control is HtmlSelect) { ((HtmlSelect)control).Value = value; } else if (control is HtmlTextArea) { ((HtmlTextArea)control).Value = value; } else { cannotHandle = true; } } else if (control is HtmlImage) { ((HtmlImage)control).Src = value; } else if (control is HtmlTitle) { ((HtmlTitle)control).Text = value; } else { cannotHandle = true; } } else if (control is WebControl) // WebControls { if (control is ListControl) { ListControl list = (ListControl)control; string[] selValues = GetMultiValue(name); if (selValues != null && selValues.Length > 0) { WebUtil.SetSelectedValues(list, selValues); } } else if (control is ITextControl) { ITextControl txt = (ITextControl)control; txt.Text = value; } else if (control is ICheckBoxControl) { ICheckBoxControl chk = (ICheckBoxControl)control; chk.Checked = Cast.Bool(value); } else { cannotHandle = true; } } else { cannotHandle = true; } } if (cannotHandle) { throw new Exception(string.Format("It hasn't implemented the value getter for control {0}, id is {1};\n\t you would better get the value by youself and then add the value use Push()! ", control.GetType().FullName, control.ID)); } }
public static string FormatBool(object value, string trueString, string falseString) { bool castValue = Cast.Bool(value); return(castValue ? trueString : falseString); }
//Save Data private void SaveData() { DictionaryItem dictionaryItem = new DictionaryItem(); bool flag = true; try { if (_actionMode == Mode.AddChild) { dictionaryItem.GroupCode = txtGroupCode.Text.Trim(); } else if (_actionMode == Mode.New) { dictionaryItem.GroupCode = DictionaryItem.Root.ItemCode; } dictionaryItem.ItemCode = txtCode.Text.Trim(); dictionaryItem.Name = txtName.Text.Trim(); dictionaryItem.ItemType = Cast.Enum <DictionaryItemType>(rdlItemType.SelectedValue); switch (dictionaryItem.ItemType) { case DictionaryItemType.Boolean: dictionaryItem.BoolValue = Cast.Bool(this.ddlBoolValue.SelectedValue); break; case DictionaryItemType.Numric: dictionaryItem.NumberValue = Cast.Decimal(this.txtNumberValue.Text); break; case DictionaryItemType.String: if (this.txtStringValue.Value.Trim().Length > 1000) { dictionaryItem.StringValue = this.txtStringValue.Value.Trim().Substring(0, 1000); } else { dictionaryItem.StringValue = this.txtStringValue.Value; } break; default: break; } dictionaryItem.Note = txtNote.Value.Trim(); using (_session = new Session()) { if (IsAddNew()) { if (DictionaryItem.Exists(_session, new string[] { "ItemCode" }, new object[] { dictionaryItem.ItemCode })) { throw new ApplicationException(string.Format("代码:{0}已经存在;如果是子项,建议将组代码作为前缀", dictionaryItem.ItemCode)); } flag = dictionaryItem.Create(_session); } else { dictionaryItem.ItemCode = (this.hidItemCode.Value); flag = dictionaryItem.Update(_session, "ItemCode", "Name", "BoolValue", "NumberValue", "StringValue"); } } this.hidItemCode.Value = dictionaryItem.ItemCode.ToString(); if (flag) { WebUtil.ShowMsg(this, "操作成功", "提示"); } else { WebUtil.ShowMsg(this, "操作失败", "提示"); } } catch (UnauthorizedException ex) { WebUtil.ShowMsg(this, ex.Message, "警告"); } catch (ApplicationException ex) { WebUtil.ShowMsg(this, ex.Message, "提示"); } catch (Exception ex) { logger.Info("保存DictionaryItem", ex); WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员"); } }