/// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.MessageToObject DataRowToModel(DataRow row)
 {
     Model.MessageToObject model = new Model.MessageToObject();
     if (row != null)
     {
         if (row["AutoID"] != null && row["AutoID"].ToString() != "")
         {
             model.AutoID = long.Parse(row["AutoID"].ToString());
         }
         if (row["MsgID"] != null && row["MsgID"].ToString() != "")
         {
             model.MsgID = long.Parse(row["MsgID"].ToString());
         }
         if (row["ObjType"] != null)
         {
             model.ObjType = row["ObjType"].ToString();
         }
         if (row["ObjValue"] != null)
         {
             model.ObjValue = row["ObjValue"].ToString();
         }
     }
     return model;
 }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.MessageToObject GetModel(long AutoID)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select AutoID,MsgID,ObjType,ObjValue from MessageToObject");
     strSql.Append(" where AutoID=@AutoID limit 1");
     MySqlParameter[] parameters = {
             new MySqlParameter("@AutoID", MySqlDbType.Int64)			};
     parameters[0].Value = AutoID;
     Model.MessageToObject model = new Model.MessageToObject();
     DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);
     if (ds.Tables[0].Rows.Count > 0)
     {
         return DataRowToModel(ds.Tables[0].Rows[0]);
     }
     else
     {
         return null;
     }
 }
Beispiel #3
0
        protected void RbtnSubmit_Click(object sender, EventArgs e)
        {
            string msgType = RCB_Type.SelectedValue;
            string closeBy = "";
            if (msgType.Equals("Popup"))
            {
                closeBy = RCB_DisType.SelectedValue;
            }
            else if (msgType.Equals("Roll"))
            {
                if (!RadButton2.Checked && RTB_RollTimes.Text.Trim().Equals(""))
                {
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('滚动次数不能为空!');", true);
                    return;
                }
                closeBy = RadButton2.Checked ? "-1" : RTB_RollTimes.Text;
            }
            if (RadDatePicker1.DbSelectedDate == null)
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c", "OpenAlert('抱歉,有效期限不能为空!');", true);
                return;
            }
            DateTime availableTime = (DateTime)RadDatePicker1.DbSelectedDate;
            DateTime expiredTime = RadDatePicker2.DbSelectedDate==null? new DateTime(2050,12,31) : (DateTime)RadDatePicker2.DbSelectedDate;
            string content = TabStrip1.SelectedTab.Value.Equals("2") ? (RadButton1.Checked ? CheckStr(ContentEditor.Content) : ContentEditor.Content) : ContentText.Text;
            if (content.Trim().Equals(""))
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,公告内容不能为空!');", true);
                return;
            }
            RadTreeView regionTreeView = RadDropDownTree1.Controls[0] as RadTreeView;
            if (!RadButton5.Checked && RadListBox1.CheckedItems.Count == 0 && regionTreeView.SelectedNodes.Count == 0 && RTB_SIM.Text.Trim().Equals(""))
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,请设置对象发送条件!!');", true);
                return;
            }
            if (!RadButton5.Checked && !RadButton3.Checked && !RadButton4.Checked)
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,请选择对象条件关系!!');", true);
                return;
            }
            Model.Message msgModel = new Model.Message();
            msgModel.Contents = content;
            msgModel.MessageType = msgType;
            msgModel.DataType = TabStrip1.SelectedTab.Value.Equals("2") ? "DataType_Html" : "DataType_Text";
            msgModel.AndOr = RadButton3.Checked;
            msgModel.AvailableTime = availableTime;
            msgModel.DisappearType = closeBy;
            msgModel.ExpiredTime = expiredTime;
            msgModel.IsValid = true;
            msgModel.LastModifyTime = DateTime.Now;
            msgModel.Memo = "";
            msgModel.Orders = 0;
            msgModel.Publisher = user.UserInfo.UserID;
            long msgId = 0;
            bool isAdd = false;
            Model.Log logModel = new Model.Log();
            try
            {
                logModel.OperationItem = "添加公告";
                logModel.Operator = user.UserInfo.UserID;
                logModel.OperationTime = DateTime.Now;
                logModel.OperationDetail =  "类型:"+msgType ;
                msgId =msg.Add(msgModel);
                if (msgId > 0)
                {
                    if (RadButton5.Checked)
                    {
                        Model.MessageToObject mtoModel = new Model.MessageToObject();
                        mtoModel.MsgID = msgId;
                        mtoModel.ObjType = "2";
                        mtoModel.ObjValue = "";
                        isAdd = mto.Add(mtoModel);
                    }
                    else
                    {
                        //身份
                        isAdd = true;
                        foreach (RadListBoxItem rbi in RadListBox1.CheckedItems)
                        {
                            isAdd = false;
                            Model.MessageToObject mtoModel = new Model.MessageToObject();
                            mtoModel.MsgID = msgId;
                            mtoModel.ObjType = "0";
                            mtoModel.ObjValue = rbi.Value;
                            isAdd = mto.Add(mtoModel);
                            if (!isAdd)
                            {
                                break;
                            }
                        }
                        //区域
                        if (isAdd)
                        {
                            isAdd = true;
                            if (!regionTreeView.SelectedValue.Equals("Area_Jfs"))
                            {
                                isAdd = false;
                                Model.MessageToObject mtoModel = new Model.MessageToObject();
                                mtoModel.MsgID = msgId;
                                mtoModel.ObjType = "0";
                                mtoModel.ObjValue = regionTreeView.SelectedValue;
                                isAdd = mto.Add(mtoModel);
                            }
                        }
                        //用户
                        if (isAdd)
                        {
                            isAdd = true;
                            if (RTB_SIM.Text.Trim() != "")
                            {
                                string[] SimNoArr = RTB_SIM.Text.Split(',');
                                foreach (string simNo in SimNoArr)
                                {
                                    if (!simNo.Trim().Equals(""))
                                    {
                                        isAdd = false;
                                        Model.MessageToObject mtoModel = new Model.MessageToObject();
                                        mtoModel.MsgID = msgId;
                                        mtoModel.ObjType = "1";
                                        mtoModel.ObjValue = simNo.Trim();
                                        isAdd = mto.Add(mtoModel);
                                        if (!isAdd)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                    }
                }
                if (msgId != 0 && isAdd)
                {
                    logModel.Memo = "成功";
                }
                else
                {
                    logModel.Memo = "失败!";
                }
            }
            catch (Exception ex)
            {
                logModel.Memo = "异常:" + ex.Message;
            }
            finally
            {
                log.Add(logModel);
                if (msgId != 0 && isAdd)
                {
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c", "OpenAlert('恭喜!编辑成功!');", true);
                }
                else
                {
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c3", "OpenAlert('抱歉!编辑失败!');", true);
                }
            }
        }