예제 #1
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(MBusinessData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into MBusiness(");
            strSql.Append("functionNo,empId,recordValue,messageTitle,acceptEmp,sendTime,isRead,readTime)");
            strSql.Append(" values (");
            strSql.Append("@functionNo,@empId,@recordValue,@messageTitle,@acceptEmp,@sendTime,@isRead,@readTime)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@functionNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@empId", SqlDbType.Int),
                    new SqlParameter("@recordValue", SqlDbType.NVarChar,50),
                    new SqlParameter("@messageTitle", SqlDbType.NVarChar,200),
                    new SqlParameter("@acceptEmp", SqlDbType.NVarChar,50),
                    new SqlParameter("@sendTime", SqlDbType.DateTime),
                    new SqlParameter("@isRead", SqlDbType.Bit),
                    new SqlParameter("@readTime", SqlDbType.DateTime)
                };
            parameters[0].Value = model.functionNo;
            parameters[1].Value = model.empId;
            parameters[2].Value = model.recordValue;
            parameters[3].Value = model.messageTitle;
            parameters[4].Value = model.acceptEmp;
            parameters[5].Value = model.sendTime == string.Empty ? null : model.sendTime;
            parameters[6].Value = model.isRead;
            parameters[7].Value = model.readTime == string.Empty ? null : model.readTime;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
예제 #2
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(MBusinessData model)
 {
     return this.businessDB.ModifyRecord(model);
 }
예제 #3
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(MBusinessData model)
 {
     return this.businessDB.AddRecord(model);
 }
예제 #4
0
 /// <summary>
 /// ������Ϣ���Ѷ�״̬
 /// </summary>
 /// <param name="runId">��������¼Id</param>
 public void SetReaded(int businessId)
 {
     MBusinessData model = new MBusinessData();
     try
     {
         //���¹�������¼״̬
         model = this.businessBB.GetModel(businessId);
         model.isRead = true;
         this.businessBB.ModifyRecord(model);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #5
0
        /// <summary>
        /// ������Ϣ��
        /// </summary>
        /// <param name="functionNo">��Ϣ���</param>
        /// <param name="recordValue">����ֵ</param>
        /// <param name="recordTitle">����</param>
        /// <param name="useEmpId">������id</param>
        /// <param name="acceptEmpId">������id</param>
        public void Send(string functionNo, string recordValue, string recordTitle, int empId, int acceptEmpId)
        {
            //д����Ϣ���б�����
            MBusinessFunctionBB businessFunctionBB = new MBusinessFunctionBB();
            HEemployeeBB userBB = new HEemployeeBB();
            MBusinessData businessData = new MBusinessData();
            MBusinessFunctionData businessFunctionData = new MBusinessFunctionData();

            try
            {
                businessData.functionNo = functionNo;
                businessData.recordValue = recordValue;
                businessData.messageTitle = recordTitle;
                businessData.empId = empId;
                businessData.sendTime = DateTime.Now.ToString();
                businessData.isRead = false;

                //�ж���Ϣ��ִ����
                if (acceptEmpId != 0)
                {
                    businessData.acceptEmp = "p___" + acceptEmpId.ToString();
                }
                else
                {
                    businessFunctionData = businessFunctionBB.GetModel(functionNo);
                    string useEmpId = "";
                    if (businessFunctionData.isUseEmpAccept || businessFunctionData.isUseEmpLeaderAccept)
                    {
                        //ȡ��ԭʼ����������
                        string workTableNm;
                        string recordKeyField;
                        bool keyIsInt = false;
                        DataSet ds = new DataSet();

                        ds = businessFunctionBB.GetVList("functionNo='" + functionNo + "'");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            throw new Exception("�Ҳ�����Ϣ��������¼���޷�������Ϣ��");
                        }
                        DataRow row = ds.Tables[0].Rows[0];

                        workTableNm = Convert.ToString(row["tableNm"]);
                        recordKeyField = Convert.ToString(row["recordKeyField"]);
                        if (row["keyIsInt"] != DBNull.Value)
                        {
                            keyIsInt = Convert.ToBoolean(row["keyIsInt"]);
                        }

                        string strSql = "select " + businessFunctionData.useEmpField + " from " + workTableNm;
                        if (keyIsInt)
                        {
                            strSql += " where " + recordKeyField + "=" + recordValue;
                        }
                        else
                        {
                            strSql += " where " + recordKeyField + "='" + recordValue + "'";
                        }

                        ds.Reset();
                        ds = this.commBB.Query(strSql);
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            throw new Exception("��Ϣ���������ò���ȷ���޷�������Ϣ��");
                        }
                        row = ds.Tables[0].Rows[0];
                        useEmpId = Convert.ToString(row[0]);
                    }

                    if (businessFunctionData.isUseEmpAccept)
                    {
                        businessData.acceptEmp = "p___" + useEmpId;
                    }
                    else if (businessFunctionData.isUseEmpLeaderAccept)
                    {
                        //ȡ��ԭʼ���������˵IJ��Ÿ�����
                        DataSet ds = new DataSet();
                        ds = userBB.GetList("empId=" + useEmpId);
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            throw new Exception("��Ա�����쵼û�����ã��޷�������Ϣ��");
                        }
                        DataRow row = ds.Tables[0].Rows[0];

                        //����н�ɫ���壬���ɾ��иý�ɫ�IJ��Ÿ����˽���
                        if (businessFunctionData.acceptEmp != "")
                        {
                            businessData.acceptEmp = businessFunctionData.acceptEmp.Replace("R_", "R_" + row["nowDepartId"].ToString());
                        }
                        else
                        {
                            businessData.acceptEmp = "p___" + row["departLeader"].ToString();
                        }
                    }
                    else
                    {
                        businessData.acceptEmp = businessFunctionData.acceptEmp;
                    }
                }

                this.businessBB.AddRecord(businessData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                businessFunctionBB.Dispose();
                userBB.Dispose();
            }
        }
예제 #6
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(MBusinessData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update MBusiness set ");
            strSql.Append("functionNo=@functionNo,");
            strSql.Append("empId=@empId,");
            strSql.Append("recordValue=@recordValue,");
            strSql.Append("messageTitle=@messageTitle,");
            strSql.Append("acceptEmp=@acceptEmp,");
            strSql.Append("sendTime=@sendTime,");
            strSql.Append("isRead=@isRead,");
            strSql.Append("readTime=@readTime");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@functionNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@empId", SqlDbType.Int),
                    new SqlParameter("@recordValue", SqlDbType.NVarChar,50),
                    new SqlParameter("@messageTitle", SqlDbType.NVarChar,200),
                    new SqlParameter("@acceptEmp", SqlDbType.NVarChar,50),
                    new SqlParameter("@sendTime", SqlDbType.DateTime),
                    new SqlParameter("@isRead", SqlDbType.Bit),
                    new SqlParameter("@readTime", SqlDbType.DateTime)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.functionNo;
            parameters[2].Value = model.empId;
            parameters[3].Value = model.recordValue;
            parameters[4].Value = model.messageTitle;
            parameters[5].Value = model.acceptEmp;
            parameters[6].Value = model.sendTime == string.Empty ? null : model.sendTime;
            parameters[7].Value = model.isRead;
            parameters[8].Value = model.readTime == string.Empty ? null : model.readTime;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
예제 #7
0
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="id">����ֵ</param>
        /// <returns>model</returns>
        public MBusinessData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from MBusiness");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            MBusinessData model = new MBusinessData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["functionNo"] != DBNull.Value)
                {
                    model.functionNo = Convert.ToString(row["functionNo"]);
                }
                if (row["empId"] != DBNull.Value)
                {
                    model.empId = Convert.ToInt32(row["empId"]);
                }
                if (row["recordValue"] != DBNull.Value)
                {
                    model.recordValue = Convert.ToString(row["recordValue"]);
                }
                if (row["messageTitle"] != DBNull.Value)
                {
                    model.messageTitle = Convert.ToString(row["messageTitle"]);
                }
                if (row["acceptEmp"] != DBNull.Value)
                {
                    model.acceptEmp = Convert.ToString(row["acceptEmp"]);
                }
                if (row["sendTime"] != DBNull.Value)
                {
                    model.sendTime = Convert.ToString(row["sendTime"]);
                }
                if (row["isRead"] != DBNull.Value)
                {
                    model.isRead = Convert.ToBoolean(row["isRead"]);
                }
                if (row["readTime"] != DBNull.Value)
                {
                    model.readTime = Convert.ToString(row["readTime"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }