/// <summary>
        /// Saves a record to the Employee table.
        /// </summary>
        private DynamicParameters Param(DispatchOutEntity dispatchout, string action = "add")
        {
            var p = new DynamicParameters();

            if (action == "add")
            {
                p.Add("@Id", dbType: DbType.Int32, direction: ParameterDirection.Output);
                p.Add("@CreateBy", dispatchout.CreateBy);
                p.Add("@CreatedDate", dispatchout.CreatedDate);
            }
            else
            {
                p.Add("@Id", dispatchout.Id);
                p.Add("@ModifiedBy", dispatchout.ModifiedBy);
                p.Add("@ModifiedDate", dispatchout.ModifiedDate);
            }
            p.Add("@DispatchNo", dispatchout.DispatchNo);
            p.Add("@DispatchName", dispatchout.DispatchName);
            p.Add("@DispatchType", dispatchout.DispatchType);
            p.Add("@Priority", dispatchout.Priority);
            p.Add("@DateWrite", dispatchout.DateWrite);
            p.Add("@DispatchStatus", dispatchout.DispatchStatus);
            p.Add("@WriterId", dispatchout.WriterId);
            p.Add("@DepartmentId", dispatchout.DepartmentId);
            p.Add("@ApproverId", dispatchout.ApproverId);
            p.Add("@ChiefOfStaffId", dispatchout.ChiefOfStaffId);
            p.Add("@Note", dispatchout.Note);
            p.Add("@FileId", dispatchout.FileId);
            p.Add("@Description", dispatchout.Description);



            return(p);
        }
        public int Insert(DispatchOutEntity dispatchout)
        {
            int  res  = 0;
            bool flag = false;

            try
            {
                var p = Param(dispatchout);
                flag = (bool)unitOfWork.ProcedureExecute("ptgroup_DispatchOut_Insert", p);
                if (flag)
                {
                    res = p.Get <int>("@Id");
                }
                else
                {
                    res = 0;
                }
            }
            catch (Exception ex)
            {
                Logging.PutError(ex.Message, ex);
                throw;
            }
            return(res);
        }
        ///Update

        public bool Update(DispatchOutEntity dispatchout)
        {
            bool res = false;

            try
            {
                var p = Param(dispatchout, "edit");
                res = (bool)unitOfWork.ProcedureExecute("ptgroup_DispatchOut_Update", p);
                return(res);
            }
            catch (Exception ex)
            {
                Logging.PutError(ex.Message, ex);
                throw;
            }
        }
        public bool UpdateFileId(DispatchOutEntity dispatchout)
        {
            bool res = false;

            try
            {
                var p = new DynamicParameters();
                p.Add("@Id", dispatchout.Id);
                p.Add("@FileId", dispatchout.FileId);
                res = (bool)unitOfWork.ProcedureExecute("ptgroup_DispatchOut_UpdateFileId", p);
                return(res);
            }
            catch (Exception ex)
            {
                Logging.PutError(ex.Message, ex);
                throw;
            }
        }