/// <summary>
        /// 修改权限
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RG_Power_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            Ccb_CheckedChanged(e);
            var editedItem = e.Item as GridEditableItem;
            var info       = new CostReportAuditingInfo();

            if (editedItem != null)
            {
                info.PowerId            = new Guid(editedItem.GetDataKeyValue("PowerId").ToString());
                info.AuditingFilialeId  = new Guid(((DropDownList)editedItem.FindControl("DDL_Filiale")).SelectedValue);
                info.AuditingBranchId   = new Guid(((DropDownList)editedItem.FindControl("DDL_Branch")).SelectedValue);
                info.AuditingPositionId = new Guid(((DropDownList)editedItem.FindControl("DDL_Position")).SelectedValue);
            }
            info.MinAmount      = -1;
            info.MaxAmount      = -1;
            info.ReportBranchId = BranchID;
            if (editedItem != null)
            {
                info.Description = ((TextBox)editedItem.FindControl("TB_Description")).Text;
            }
            info.Kind = (int)CostReportAuditingType.Invoice;
            try
            {
                _costReportAuditingPower.UpdatePower(info);
                RG_Power.Rebind();
                CheckChanged = false;
            }
            catch (Exception ex)
            {
                RAM.Alert("权限修改失败!" + ex.Message);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 修改权限
 /// </summary>
 /// <param name="info">权限模型</param>
 public void UpdatePower(CostReportAuditingInfo info)
 {
     SqlParameter[] parms = GetParameter();
     parms[0].Value     = info.PowerId;
     parms[1].Value     = info.AuditingFilialeId;
     parms[2].Value     = info.AuditingBranchId;
     parms[3].Value     = info.AuditingPositionId;
     parms[4].Value     = info.MinAmount;
     parms[4].Precision = 18;
     parms[4].Scale     = 4;
     parms[5].Value     = info.MaxAmount;
     parms[5].Precision = 18;
     parms[5].Scale     = 4;
     parms[6].Value     = info.ReportBranchId;
     parms[7].Value     = info.Description;
     parms[8].Value     = info.Kind;
     try
     {
         SqlHelper.ExecuteNonQuery(GlobalConfig.ERP_DB_NAME, false, SQL_UPDATE_POWER, parms);
     }
     catch (Exception ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 获取权限
        /// </summary>
        /// <returns></returns>
        public IList <CostReportAuditingInfo> GetPowerList()
        {
            IList <CostReportAuditingInfo> list = new List <CostReportAuditingInfo>();

            using (var dr = SqlHelper.ExecuteReader(GlobalConfig.ERP_DB_NAME, true, SQL_GET_POWER, null))
            {
                while (dr.Read())
                {
                    var info = new CostReportAuditingInfo(dr.GetGuid(0), dr.GetGuid(1), dr.GetGuid(2), dr.GetGuid(3), dr.GetDecimal(4), dr.GetDecimal(5), dr.GetString(6), dr[7] == DBNull.Value ? "" : dr.GetString(7), dr[8] == DBNull.Value ? 0 : dr.GetInt32(8));
                    list.Add(info);
                }
            }
            return(list);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RgPowerInsertCommand(object sender, GridCommandEventArgs e)
        {
            var editedItem = e.Item as GridEditableItem;
            var info       = new CostReportAuditingInfo {
                PowerId = Guid.NewGuid()
            };

            if (editedItem != null)
            {
                info.AuditingFilialeId  = new Guid(((DropDownList)editedItem.FindControl("DDL_Filiale")).SelectedValue);
                info.AuditingBranchId   = new Guid(((DropDownList)editedItem.FindControl("DDL_Branch")).SelectedValue);
                info.AuditingPositionId = new Guid(((DropDownList)editedItem.FindControl("DDL_Position")).SelectedValue);
                info.MinAmount          = decimal.Parse(((TextBox)editedItem.FindControl("TB_MinAmount")).Text);
                info.MaxAmount          = decimal.Parse(((TextBox)editedItem.FindControl("TB_MaxAmount")).Text);
                string strReportBranchIds = string.Empty;
                var    rpReportFiliale    = (Repeater)editedItem.FindControl("RP_ReportFiliale");
                strReportBranchIds = (from RepeaterItem item in rpReportFiliale.Items
                                      select(CheckBoxList) item.FindControl("cblReportBranch"))
                                     .Aggregate(strReportBranchIds, (current1, cblReportBranch) => cblReportBranch.Items.Cast <ListItem>().Where(listItem => listItem.Selected).Aggregate(current1, (current, listItem) => current + (listItem.Value + ",")));
                info.ReportBranchId = strReportBranchIds;
            }
            if (editedItem != null)
            {
                info.Description = ((TextBox)editedItem.FindControl("TB_Description")).Text;
            }
            info.Kind = (int)CostReportAuditingType.Auditing;
            try
            {
                CostReportAuditingInfo auditingInfo = _costReportAuditingPowerDao.GetPowerList().FirstOrDefault(p => p.AuditingFilialeId == info.AuditingFilialeId && p.AuditingBranchId == info.AuditingBranchId &&
                                                                                                                p.AuditingPositionId == info.AuditingPositionId && p.ReportBranchId == info.ReportBranchId);
                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (auditingInfo != null)
                    {
                        _costReportAuditingPowerDao.DeletePower(auditingInfo.PowerId);
                    }
                    _costReportAuditingPowerDao.InsertPower(info);
                    ts.Complete();
                }
                RG_Power.Rebind();
            }
            catch (Exception ex)
            {
                RAM.Alert("权限添加失败!" + ex.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 申报部门权限
        /// </summary>
        /// <param name="info">权限模型</param>
        public void UpdateReportPower(CostReportAuditingInfo info)
        {
            var parms = new[] {
                new SqlParameter(PARM_POWER_ID, SqlDbType.UniqueIdentifier),
                new SqlParameter(PARM_REPORT_BRANCH_ID, SqlDbType.VarChar, 256)
            };

            parms[0].Value = info.PowerId;
            parms[1].Value = info.ReportBranchId;
            try
            {
                SqlHelper.ExecuteNonQuery(GlobalConfig.ERP_DB_NAME, false, SQL_UPDATE_REPORT_POWER, parms);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RG_Power_InsertCommand(object sender, GridCommandEventArgs e)
        {
            Ccb_CheckedChanged(e);
            var editedItem = e.Item as GridEditableItem;
            var info       = new CostReportAuditingInfo {
                PowerId = Guid.NewGuid()
            };

            if (editedItem != null)
            {
                info.AuditingFilialeId  = new Guid(((DropDownList)editedItem.FindControl("DDL_Filiale")).SelectedValue);
                info.AuditingBranchId   = new Guid(((DropDownList)editedItem.FindControl("DDL_Branch")).SelectedValue);
                info.AuditingPositionId = new Guid(((DropDownList)editedItem.FindControl("DDL_Position")).SelectedValue);
            }
            info.MinAmount      = -1;
            info.MaxAmount      = -1;
            info.ReportBranchId = BranchID;
            if (editedItem != null)
            {
                info.Description = ((TextBox)editedItem.FindControl("TB_Description")).Text;
            }
            info.Kind = (int)CostReportAuditingType.Invoice;
            try
            {
                CostReportAuditingInfo auditingInfo = _costReportAuditingPower.GetPowerList().FirstOrDefault(p => p.AuditingFilialeId == info.AuditingFilialeId && p.AuditingBranchId == info.AuditingBranchId &&
                                                                                                             p.AuditingPositionId == info.AuditingPositionId && p.ReportBranchId == info.ReportBranchId);
                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (auditingInfo != null)
                    {
                        _costReportAuditingPower.DeletePower(auditingInfo.PowerId);
                    }
                    _costReportAuditingPower.InsertPower(info);
                    ts.Complete();
                }
                RG_Power.Rebind();
                CheckChanged = false;
            }
            catch (Exception ex)
            {
                RAM.Alert("权限添加失败!" + ex.Message);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 修改权限
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RgPowerUpdateCommand(object sender, GridCommandEventArgs e)
        {
            var editedItem = e.Item as GridEditableItem;
            var info       = new CostReportAuditingInfo();

            if (editedItem != null)
            {
                info.PowerId            = new Guid(editedItem.GetDataKeyValue("PowerId").ToString());
                info.AuditingFilialeId  = new Guid(((DropDownList)editedItem.FindControl("DDL_Filiale")).SelectedValue);
                info.AuditingBranchId   = new Guid(((DropDownList)editedItem.FindControl("DDL_Branch")).SelectedValue);
                info.AuditingPositionId = new Guid(((DropDownList)editedItem.FindControl("DDL_Position")).SelectedValue);
                info.MinAmount          = decimal.Parse(((TextBox)editedItem.FindControl("TB_MinAmount")).Text);
                info.MaxAmount          = decimal.Parse(((TextBox)editedItem.FindControl("TB_MaxAmount")).Text);
                string strReportBranchIds = string.Empty;
                var    rpReportFiliale    = (Repeater)editedItem.FindControl("RP_ReportFiliale");
                strReportBranchIds = (from RepeaterItem item in rpReportFiliale.Items
                                      select(CheckBoxList) item.FindControl("cblReportBranch"))
                                     .Aggregate(strReportBranchIds, (current1, cblReportBranch) => cblReportBranch.Items.Cast <ListItem>()
                                                .Where(listItem => listItem.Selected).Aggregate(current1, (current, listItem) => current + (listItem.Value + ",")));
                info.ReportBranchId = strReportBranchIds;
            }
            if (editedItem != null)
            {
                info.Description = ((TextBox)editedItem.FindControl("TB_Description")).Text;
            }
            info.Kind = (int)CostReportAuditingType.Auditing;
            try
            {
                _costReportAuditingPowerDao.UpdatePower(info);
                RG_Power.Rebind();
            }
            catch (Exception ex)
            {
                RAM.Alert("权限修改失败!" + ex.Message);
            }
        }