Exemplo n.º 1
0
        /// <summary>
        ///  ����һ������
        /// </summary>
        public bool Add(DepartmentInfo model,out int DeptID)
        {
            string procName = "OA_SP_SM_Department_ADD";
            LogBuilder log = new LogBuilder();
            #region ��־��Ϣ
            log.Desc = "��Ӳ���";

            log.Method = MethodBase.GetCurrentMethod().Name;
            log.Path = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DepartmentInfo", model);
            #endregion
             DeptID = 0;
            try
            {
                int rowsAffected;
                SqlParameter[] parameters = {
                    new SqlParameter("@DepID", SqlDbType.Int,4),
                    new SqlParameter("@DepName", SqlDbType.VarChar,50),
                    new SqlParameter("@ParentID", SqlDbType.Int,4),
                    new SqlParameter("@Remark", SqlDbType.VarChar,200),
                    new SqlParameter("@State", SqlDbType.Int,4),
                    new SqlParameter("@Creator", SqlDbType.Int,4)};
                parameters[0].Direction = ParameterDirection.Output;
                parameters[1].Value = model.DepName;
                parameters[2].Value = model.ParentID;
                parameters[3].Value = model.Remark;
                parameters[4].Value = model.State;
                parameters[5].Value = model.Creator;

                Mssql.ExecuteProc(procName, parameters, out rowsAffected);
                if (rowsAffected > 0)
                {
                    if (parameters[0] != null)
                    {
                        DeptID = (int)parameters[0].Value;
                        log.Append("DeptID", DeptID, ParamDirection.OUT);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
            }
            return DeptID>0;
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DepartmentDAL departDal = new DepartmentDAL();
            DepartmentInfo departInfo = new DepartmentInfo();
            departInfo.DepName = txtDepName.Text;
            departInfo.Remark = txtRemark.Value;

            if (hidparentID.Value == "")
            {
                departInfo.ParentID = 0;
            }
            else
            {
                departInfo.ParentID = Convert.ToInt32(hidparentID.Value);
            }
            bool result = departDal.Exists(0, departInfo.DepName);
            if (result)
            {
                int depID = 0;
                result =departDal.Add(departInfo,out depID);
                if (result)
                {
                    TsOAPage.ShowMsgRefresh(this.Page, lang.SaveSuccess);
                    return;
                }
                else
                {
                    TsOAPage.ShowMsgRefresh(this.Page, lang.SaveFail);
                    return;
                }
            }
            else
            {
                TsOAPage.ShowMsgRefresh(this.Page, string.Format(lang.NameExists,lang.DepName));
                return;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// ��ѯ�����б�
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalRows"></param>
        /// <param name="ParentID">�ϼ�ID</param>
        /// <returns></returns>
        public IList<DepartmentInfo> GetList(int pageSize, int pageIndex, out int totalRows,int ParentID=-1)
        {
            List<DepartmentInfo> DeparList = null;
            DepartmentInfo ui = null;
            totalRows = 0;
            MssqlDatabase database = null;
            LogBuilder log = new LogBuilder();
            try
            {
                string procName = "OA_SP_SM_Department_GetList";
                #region ��־��Ϣ
                log.Desc = "��ò��������б�";

                log.Method = MethodBase.GetCurrentMethod().Name;
                log.Path = MethodBase.GetCurrentMethod().DeclaringType.FullName;
                log.StroreProcedure = procName;

                log.Append("PageSize", pageSize.ToString());
                log.Append("PageIndex", pageIndex.ToString());
                log.Append("ParentID", ParentID.ToString());
                #endregion

                SqlParameter[] param ={

                 database.MakeInParam("@ParentID",SqlDbType.Int,4,ParentID),
                  database.MakeInParam("@PageSize", SqlDbType.Int,4, pageSize),
                  database.MakeInParam("@PageIndex", SqlDbType.Int,4,pageIndex),

                  database.MakeOutParam("@TotalRows",SqlDbType.Int,4)
                };
                DataTable dt = null;
                database.ExecuteProc(procName, param, out dt);
                totalRows = SqlComponents.ReaderGetInt32(param[3].Value);

                log.Append("TotalRows", totalRows.ToString(), ParamDirection.INOUT);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DeparList = new List<DepartmentInfo>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ui = new DepartmentInfo();
                        ui.RowId = SqlComponents.ReaderGetInt32(dt.Rows[i]["rowid"]);
                        ui.DepID = SqlComponents.ReaderGetInt32(dt.Rows[i]["DepID"]);
                        ui.ParentID = SqlComponents.ReaderGetInt32(dt.Rows[i]["ParentID"]);
                        ui.State = SqlComponents.ReaderGetInt32(dt.Rows[i]["State"]);
                        ui.DepName = SqlComponents.ReaderGetString(dt.Rows[i]["DepName"]);
                        ui.Remark = SqlComponents.ReaderGetString(dt.Rows[i]["Remark"]);
                        DeparList.Add(ui);
                    }
                }
                return DeparList;
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (database != null)
                {
                    database.Close();
                }
            }
            return null;
        }
Exemplo n.º 4
0
        /// <summary>
        ///  ����һ������
        /// </summary>
        public bool Update(DepartmentInfo model)
        {
            string procName = "OA_SP_SM_Department_Update";
            LogBuilder log = new LogBuilder();

            #region ��־��Ϣ
            log.Desc = "���²���";

            log.Method = MethodBase.GetCurrentMethod().Name;
            log.Path = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DepartmentInfo", model);
            #endregion

            try
            {
                int rowsAffected = 0;
                SqlParameter[] parameters = {
                    new SqlParameter("@DepID", SqlDbType.Int,4),
                    new SqlParameter("@DepName", SqlDbType.VarChar,50),
                    new SqlParameter("@ParentID", SqlDbType.Int,4),
                    new SqlParameter("@Remark", SqlDbType.VarChar,200),
                    new SqlParameter("@State", SqlDbType.Int,4),
                    new SqlParameter("@ModifyTime", SqlDbType.DateTime,4),
                    new SqlParameter("@ModityUesrID", SqlDbType.Int,4)};
                parameters[0].Value = model.DepID;
                parameters[1].Value = model.DepName;
                parameters[2].Value = model.ParentID;
                parameters[3].Value = model.Remark;
                parameters[4].Value = model.State;
                parameters[5].Value = model.Created;
                parameters[6].Value = model.Creator;
                Mssql.ExecuteProc(procName, parameters, out rowsAffected);
                if (rowsAffected > 0)
                {
                    return true;
                }

            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
            }
            return false;
        }
Exemplo n.º 5
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public DepartmentInfo GetDepartmentInfo(int DepID)
        {
            DepartmentInfo model = null;
            string procName = "OA_SP_SM_Department_GetModel";
            LogBuilder log = new LogBuilder();

            #region ��־��Ϣ
            log.Desc = "��ȡ������Ϣ";

            log.Method = MethodBase.GetCurrentMethod().Name;
            log.Path = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DepID", DepID);
            #endregion

            try
            {

                SqlParameter[] parameters = {
                    new SqlParameter("@DepID", SqlDbType.Int,4)
            };
                parameters[0].Value = DepID;

                DataTable dt = Mssql.ExecuteProcDt(procName, parameters);
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    model = new DepartmentInfo();
                    model.DepID = DepID;
                    model.DepName = SqlComponents.ReaderGetString(dr["DepName"]);
                    model.ParentID = SqlComponents.ReaderGetInt32(dr["ParentID"]);
                    model.Remark = SqlComponents.ReaderGetString(dr["Remark"]);
                    model.State = SqlComponents.ReaderGetInt32(dr["State"]);
                    return model;
                }
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
            }
                return null;
        }