private string DoAdd(out int id)
 {
     id = 0;
     Model.ReceiptPayDetail model = new Model.ReceiptPayDetail();
     BLL.ReceiptPayDetail   bll   = new BLL.ReceiptPayDetail();
     manager            = GetAdminInfo();
     model.rpd_type     = true;
     model.rpd_oid      = oID;
     model.rpd_cid      = Utils.StrToInt(hCusId.Value, 0);
     model.rpd_content  = txtContent.Text.Trim();
     model.rpd_money    = Utils.StrToDecimal(txtMoney.Text.Trim(), 0);
     model.rpd_foredate = ConvertHelper.toDate(txtforedate.Text.Trim());
     model.rpd_method   = Utils.StrToInt(ddlmethod.SelectedValue, 0);
     //model.rpd_content = txtContent.Text.Trim();
     model.rpd_personNum  = manager.user_name;
     model.rpd_personName = manager.real_name;
     model.rpd_adddate    = DateTime.Now;
     model.rpd_flag1      = 2;
     //model.rpd_area = manager.area;
     model.rpd_cbid = 0;
     if (model.rpd_money < 0)
     {
         model.rpd_cbid = Utils.StrToInt(hBankId.Value, 0);
     }
     return(bll.AddReceiptPay(model, manager, out id));
 }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.ReceiptPayDetail model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            //利用反射获得属性的所有公共属性
            PropertyInfo[]      pros  = model.GetType().GetProperties();
            List <SqlParameter> paras = new List <SqlParameter>();

            strSql.Append("update MS_ReceiptPayDetail set ");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("rpd_id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + "=@" + pi.Name + ",");                          //声明参数
                        paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(" where rpd_id=@id ");
            paras.Add(new SqlParameter("@id", model.rpd_id));
            return(DbHelperSQL.ExecuteSql(strSql.ToString(), paras.ToArray()) > 0);
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.ReceiptPayDetail GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.ReceiptPayDetail model = new Model.ReceiptPayDetail();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                str1.Append(p.Name + ",");//拼接字段
            }
            strSql.Append("select top 1 " + str1.ToString().Trim(','));
            strSql.Append(" from MS_ReceiptPayDetail");
            strSql.Append(" where rpd_id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;
            DataTable dt = DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                return(DataRowToModel(dt.Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        private string DoAdd(out int rpid)
        {
            rpid = 0;
            Model.ReceiptPay model = new Model.ReceiptPay();
            BLL.ReceiptPay   bll   = new BLL.ReceiptPay();

            manager           = GetAdminInfo();
            model.rp_type     = true;
            model.rp_cid      = Utils.StrToInt(hCusId.Value, 0);
            model.rp_money    = Utils.StrToDecimal(txtMoney.Text.Trim(), 0);
            model.rp_foredate = ConvertHelper.toDate(txtforedate.Text.Trim());
            model.rp_method   = Utils.StrToInt(ddlmethod.SelectedValue, 0);
            model.rp_content  = txtContent.Text.Trim();
            model.rp_cbid     = 0;
            if (model.rp_money < 0)
            {
                model.rp_cbid = Utils.StrToInt(hBankId.Value, 0);
            }
            //在客户对账明细的账单打包时不是预收款
            bool flag = true;

            if (!string.IsNullOrEmpty(oidStr))
            {
                flag = false;
            }
            string result = bll.Add(model, manager, txtCenum.Text.Trim(), txtCedate.Text.Trim(), out rpid, flag);

            if (string.IsNullOrEmpty(result))
            {
                if (!string.IsNullOrEmpty(oidStr) && model.rp_money == Utils.StrToDecimal(_tMoney, 0))
                {
                    JArray ja = JArray.Parse(oidStr);
                    foreach (JObject item in ja)
                    {
                        Model.ReceiptPayDetail rpdModel = new Model.ReceiptPayDetail();
                        rpdModel.rpd_type       = true;
                        rpdModel.rpd_rpid       = rpid;
                        rpdModel.rpd_oid        = item["oid"].ToString();
                        rpdModel.rpd_cid        = Utils.StrToInt(_cid, 0);
                        rpdModel.rpd_num        = _chk;
                        rpdModel.rpd_money      = Utils.StrToDecimal(item["money"].ToString(), 0);
                        rpdModel.rpd_foredate   = model.rp_foredate;
                        rpdModel.rpd_method     = model.rp_method;
                        rpdModel.rpd_personName = manager.real_name;
                        rpdModel.rpd_personNum  = manager.user_name;
                        rpdModel.rpd_flag1      = 2;
                        rpdModel.rpd_flag2      = 2;
                        rpdModel.rpd_flag3      = 2;
                        rpdModel.rpd_adddate    = DateTime.Now;
                        rpdModel.rpd_content    = "";
                        rpdModel.rpd_cbid       = model.rp_cbid;
                        new BLL.ReceiptPayDetail().AddOrCancleDistribution(rpdModel, manager);
                    }
                }
            }
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.ReceiptPayDetail model, SqlConnection conn = null, SqlTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder(); //数据字段
            StringBuilder str2   = new StringBuilder(); //数据参数

            //利用反射获得属性的所有公共属性
            PropertyInfo[]      pros  = model.GetType().GetProperties();
            List <SqlParameter> paras = new List <SqlParameter>();

            strSql.Append("insert into MS_ReceiptPayDetail(");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("rpd_id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + ",");                                           //拼接字段
                        str2.Append("@" + pi.Name + ",");                                     //声明参数
                        paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(") values (");
            strSql.Append(str2.ToString().Trim(','));
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY;");
            object obj = 0;

            if (tran == null)
            {
                obj = DbHelperSQL.GetSingle(strSql.ToString(), paras.ToArray());
            }
            else
            {
                obj = DbHelperSQL.GetSingle(conn, tran, strSql.ToString(), paras.ToArray());
            }
            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 将对象转换实体
 /// </summary>
 public Model.ReceiptPayDetail DataRowToModel(DataRow row)
 {
     Model.ReceiptPayDetail model = new Model.ReceiptPayDetail();
     if (row != null)
     {
         //利用反射获得属性的所有公共属性
         Type modelType = model.GetType();
         for (int i = 0; i < row.Table.Columns.Count; i++)
         {
             //查找实体是否存在列表相同的公共属性
             PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName);
             if (proInfo != null && row[i] != DBNull.Value)
             {
                 proInfo.SetValue(model, row[i], null);//用索引值设置属性值
             }
         }
     }
     return(model);
 }
        private string DoEdit(int _id)
        {
            BLL.ReceiptPayDetail   bll   = new BLL.ReceiptPayDetail();
            Model.ReceiptPayDetail model = bll.GetModel(_id);
            manager = GetAdminInfo();
            string _content = string.Empty;

            if (model.rpd_cid.ToString() != hCusId.Value)
            {
                _content += "收款对象ID:" + model.rpd_cid + "→<font color='red'>" + hCusId.Value + "</font><br/>";
            }
            model.rpd_cid = Utils.StrToInt(hCusId.Value, 0);
            bool updateMoney = false;

            if (model.rpd_money.ToString() != txtMoney.Text.Trim())
            {
                updateMoney = true;
                _content   += "收款金额:" + model.rpd_money + "→<font color='red'>" + txtMoney.Text.Trim() + "</font><br/>";
            }
            model.rpd_money = Utils.StrToDecimal(txtMoney.Text.Trim(), 0);
            if (model.rpd_foredate.Value.ToString("yyyy-MM-dd") != txtforedate.Text.Trim())
            {
                _content += "预收日期:" + model.rpd_foredate.Value.ToString("yyyy-MM-dd") + "→<font color='red'>" + txtforedate.Text.Trim() + "</font><br/>";
            }
            model.rpd_foredate = ConvertHelper.toDate(txtforedate.Text.Trim());
            if (model.rpd_method.ToString() != ddlmethod.SelectedValue)
            {
                _content += "收款方式ID:" + model.rpd_method + "→<font color='red'>" + ddlmethod.SelectedItem.Text + "</font><br/>";
            }
            model.rpd_method = Utils.StrToInt(ddlmethod.SelectedValue, 0);
            if (model.rpd_content != txtContent.Text.Trim())
            {
                _content += "收款内容:" + model.rpd_content + "→<font color='red'>" + txtContent.Text.Trim() + "</font><br/>";
            }
            model.rpd_content = txtContent.Text.Trim();
            if (model.rpd_cbid != Utils.StrToInt(hBankId.Value, 0))
            {
                _content += "客户银行账号:" + model.rpd_cbid + "→<font color='red'>" + hBankId.Value + "</font><br/>";
            }
            model.rpd_cbid = Utils.StrToInt(hBankId.Value, 0);
            return(bll.Update(model, _content, manager, updateMoney));
        }
Esempio n. 8
0
 private string DoAdd(out int id)
 {
     id = 0;
     Model.ReceiptPayDetail model = new Model.ReceiptPayDetail();
     BLL.ReceiptPayDetail   bll   = new BLL.ReceiptPayDetail();
     manager              = GetAdminInfo();
     model.rpd_type       = false;
     model.rpd_oid        = oID;
     model.rpd_cid        = Utils.StrToInt(hCusId.Value, 0);
     model.rpd_money      = Utils.StrToDecimal(txtMoney.Text.Trim(), 0);
     model.rpd_foredate   = ConvertHelper.toDate(txtforedate.Text.Trim());
     model.rpd_content    = txtContent.Text.Trim();
     model.rpd_personNum  = manager.user_name;
     model.rpd_personName = manager.real_name;
     model.rpd_adddate    = DateTime.Now;
     model.rpd_cbid       = Utils.StrToInt(hBankId.Value, 0);
     model.rpd_flag1      = 0;
     model.rpd_flag2      = 0;
     model.rpd_flag3      = 0;
     //model.rpd_area = manager.area;
     if (fileUp.HasFile)
     {
         string fileext = "";
         for (int i = 0; i < fileUp.PostedFiles.Count; i++)
         {
             fileext = System.IO.Path.GetExtension(fileUp.PostedFiles[i].FileName).TrimStart('.');//jpg,jpge,png,gif
             //检查文件扩展名是否合法
             if (!CheckFileExt(fileext))
             {
                 return("不允许上传" + fileext + "类型的文件");
             }
             byte[] byteData = FileHelper.ConvertStreamToByteBuffer(fileUp.PostedFiles[i].InputStream); //获取文件流
             //检查文件大小是否合法
             if (!CheckFileSize(fileext, byteData.Length))
             {
                 return("文件超过限制的大小");
             }
         }
     }
     return(bll.AddReceiptPay(model, manager, out id));
 }
Esempio n. 9
0
        /// <summary>
        /// 分配或取消分配
        /// </summary>
        /// <param name="model"></param>
        /// <param name="manager"></param>
        /// <returns></returns>
        public string AddOrCancleDistribution(Model.ReceiptPayDetail model, Model.manager manager)
        {
            int ret = 0;

            Model.Order order = new BLL.Order().GetModel(model.rpd_oid);
            if (order == null)
            {
                return("订单不存在");
            }
            StringBuilder content = new StringBuilder();

            Model.business_log logmodel = new Model.business_log();
            if (model.rpd_money == 0)
            {
                ret = dal.delDistribution(model.rpd_rpid.Value, model.rpd_oid, model.rpd_cid.Value, model.rpd_num);
                logmodel.ol_title = "取消分配";
            }
            else
            {
                //收付款明细申请中的“收付款内容”=预收付款申请的“收付款内容”
                model.rpd_content = new BLL.ReceiptPay().GetModel(model.rpd_rpid.Value).rp_content;
                //明细的区域和订单区域保持一致
                model.rpd_area = order.personlist.Where(p => p.op_type == 1).ToArray()[0].op_area;
                dal.delDistribution(model.rpd_rpid.Value, model.rpd_oid, model.rpd_cid.Value, model.rpd_num, "add");
                ret = dal.Add(model);
                logmodel.ol_title = "新增分配";
            }
            if (ret > 0)
            {
                logmodel.ol_oid = model.rpd_oid;
                logmodel.ol_cid = model.rpd_cid.Value;
                content.Append("金额:" + model.rpd_money + "");
                logmodel.ol_content     = content.ToString();
                logmodel.ol_operateDate = DateTime.Now;
                new business_log().Add(DTEnums.ActionEnum.Distribute.ToString(), logmodel, manager.user_name, manager.real_name); //记录日志
                return("成功");
            }
            return("失败");
        }
Esempio n. 10
0
        private string DoEdit(int _id)
        {
            BLL.ReceiptPayDetail   bll   = new BLL.ReceiptPayDetail();
            Model.ReceiptPayDetail model = bll.GetModel(_id);
            manager = GetAdminInfo();
            string _content = string.Empty;
            //if (model.rpd_cid.ToString() != hCusId.Value)
            //{
            //    _content += "付款对象ID:" + model.rpd_cid + "→<font color='red'>" + hCusId.Value + "</font><br/>";
            //}
            //model.rpd_cid = Utils.StrToInt(hCusId.Value, 0);
            bool updateMoney = false;

            if (model.rpd_money.ToString() != txtMoney.Text.Trim())
            {
                if ((model.rpd_money < 0 && Utils.ObjToDecimal(txtMoney.Text.Trim(), 0) >= 0) || (model.rpd_money >= 0 && Utils.ObjToDecimal(txtMoney.Text.Trim(), 0) < 0))
                {
                    updateMoney = true;//表示金额从负数改为正数,或从正数改为负数
                }
                _content += "付款金额:" + model.rpd_money + "→<font color='red'>" + txtMoney.Text.Trim() + "</font><br/>";
            }
            model.rpd_money = Utils.StrToDecimal(txtMoney.Text.Trim(), 0);
            if (model.rpd_foredate.Value.ToString("yyyy-MM-dd") != txtforedate.Text.Trim())
            {
                _content += "预付日期:" + model.rpd_foredate.Value.ToString("yyyy-MM-dd") + "→<font color='red'>" + txtforedate.Text.Trim() + "</font><br/>";
            }
            model.rpd_foredate = ConvertHelper.toDate(txtforedate.Text.Trim());
            if (model.rpd_content != txtContent.Text.Trim())
            {
                _content += "付款内容:" + model.rpd_content + "→<font color='red'>" + txtContent.Text.Trim() + "</font><br/>";
            }
            model.rpd_content = txtContent.Text.Trim();
            if (model.rpd_cbid != Utils.StrToInt(hBankId.Value, 0))
            {
                _content += "客户银行账号:" + model.rpd_cbid + "→<font color='red'>" + hBankId.Value + "</font><br/>";
            }
            model.rpd_cbid = Utils.StrToInt(hBankId.Value, 0);
            return(bll.Update(model, _content, manager, updateMoney));
        }
Esempio n. 11
0
        /// <summary>
        /// 增加收款明细
        /// </summary>
        public int Add(Model.ReceiptPayDetail model, Model.ReceiptPay rp)
        {
            int rpid = 0, rpdid = 0;

            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();//打开数据连接
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 插入收款通知======================
                        if (rp != null)
                        {
                            rpid = new DAL.ReceiptPay().Add(rp, conn, trans);
                        }
                        #endregion

                        #region 插入收付款明细==========================

                        model.rpd_rpid = rpid;
                        rpdid          = Add(model, conn, trans);
                        if (rpdid > 0)
                        {
                            trans.Commit();
                        }
                        #endregion
                    }
                    catch
                    {
                        trans.Rollback(); //回滚事务
                        rpdid = 0;
                    }
                }
            }
            return(rpdid);
        }
Esempio n. 12
0
        /// <summary>
        /// 增加收付款明细
        /// </summary>
        public string AddReceiptPay(Model.ReceiptPayDetail model, Model.manager manager, out int id)
        {
            id = 0;
            string typeText = "收款";

            if (!model.rpd_type.Value)
            {
                typeText = "付款";
            }
            Model.Order order = new BLL.Order().GetModel(model.rpd_oid);
            if (order == null)
            {
                return("订单不存在");
            }
            if (!new BLL.permission().checkHasPermission(manager, "0401"))//如果不是财务
            {
                if (order.personlist.Where(p => p.op_number == manager.user_name && p.op_type != 3).ToArray().Length == 0)
                {
                    return("无权限添加");
                }
            }
            //收付款明细的区域和订单区域保持一致
            model.rpd_area = order.personlist.Where(p => p.op_type == 1).ToArray()[0].op_area;
            if (model.rpd_cid == 0)
            {
                return("请选择" + typeText + "对象");
            }
            if (model.rpd_money == 0)
            {
                return("请填写" + typeText + "金额");
            }
            if (model.rpd_foredate == null)
            {
                return("请选择" + (model.rpd_type.Value ? "预收" : "预付") + "日期");
            }
            if (model.rpd_type.Value && model.rpd_method == 0)
            {
                return("请选择收款方式");
            }
            Model.ReceiptPay rp = null;
            if (model.rpd_type.Value)
            {
                rp               = new Model.ReceiptPay();
                rp.rp_type       = true;
                rp.rp_cid        = model.rpd_cid;
                rp.rp_content    = model.rpd_content;
                rp.rp_money      = model.rpd_money;
                rp.rp_foredate   = model.rpd_foredate;
                rp.rp_method     = model.rpd_method;
                rp.rp_personNum  = model.rpd_personNum;
                rp.rp_personName = model.rpd_personName;
                rp.rp_isConfirm  = false;
                rp.rp_isExpect   = false;
                rp.rp_flag       = 2;
                if (rp.rp_money < 0)
                {
                    rp.rp_flag  = 0;
                    rp.rp_flag1 = 0;
                }
                rp.rp_adddate = model.rpd_adddate;
                rp.rp_area    = model.rpd_area;
                rp.rp_cbid    = model.rpd_cbid;
                if (model.rpd_money < 0)
                {
                    if (model.rpd_cbid == 0)
                    {
                        return("请选择客户银行账号");
                    }
                }
            }
            else
            {
                if (model.rpd_cbid == 0)
                {
                    return("请选择客户银行账号");
                }
                //负数金额的业务付款明细申请自动审批通过,不需要人工审批!还有负数金额的业务付款明细申请不受“应付 - 已下付款申请〉=0”限制
                if (model.rpd_money < 0)
                {
                    model.rpd_flag1      = 2;
                    model.rpd_checkTime1 = DateTime.Now;
                    model.rpd_flag2      = 2;
                    model.rpd_checkTime2 = DateTime.Now;
                    model.rpd_flag3      = 2;
                    model.rpd_checkTime3 = DateTime.Now;
                }
                else
                {
                    decimal?money = getUnPayMoney(model.rpd_cid.Value, model.rpd_oid);
                    if (model.rpd_money > money)
                    {
                        return("金额不能超过:" + money);
                    }
                }
            }

            id = dal.Add(model, rp);
            if (id > 0)
            {
                StringBuilder content = new StringBuilder();
                content.Append("订单号:" + model.rpd_oid + "<br/>");
                content.Append("" + typeText + "对象ID:" + model.rpd_cid + "<br/>");
                content.Append("" + typeText + "金额:" + model.rpd_money + "<br/>");
                content.Append("预收日期:" + model.rpd_foredate.Value.ToString("yyyy-MM-dd") + "<br/>");
                if (model.rpd_type.Value)
                {
                    content.Append("" + typeText + "方式ID:" + model.rpd_method + "<br/>");
                }
                content.Append("" + typeText + "内容:" + model.rpd_content + "<br/>");

                Model.business_log logmodel = new Model.business_log();
                logmodel.ol_oid         = model.rpd_oid;
                logmodel.ol_relateID    = id;
                logmodel.ol_cid         = model.rpd_cid.Value;
                logmodel.ol_title       = "添加" + typeText + "明细";
                logmodel.ol_content     = content.ToString();
                logmodel.ol_operateDate = DateTime.Now;
                new business_log().Add(DTEnums.ActionEnum.Add.ToString(), logmodel, manager.user_name, manager.real_name); //记录日志

                //钉钉通知
                if (!model.rpd_type.Value)
                {
                    DataTable userDt = new BLL.manager().getUserByPermission("0603", model.rpd_area).Tables[0];
                    if (userDt != null)
                    {
                        string replaceContent = model.rpd_oid + "," + model.rpd_money + "," + model.rpd_content;
                        string replaceUser    = model.rpd_personNum + "," + model.rpd_personName;
                        foreach (DataRow dr in userDt.Rows)
                        {
                            //钉钉推送通知
                            if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"])))
                            {
                                new BLL.selfMessage().sentDingMessage("添加付款通知", dr["oauth_userid"].ToString(), replaceContent, replaceUser);
                            }
                        }
                    }
                }

                return("");
            }
            return("添加失败");
        }
Esempio n. 13
0
        /// <summary>
        /// 付款明细审批
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="status"></param>
        /// <param name="remark"></param>
        /// <param name="username"></param>
        /// <param name="realname"></param>
        /// <returns></returns>
        public string checkPayDetailStatus(int id, byte?type, byte?status, string remark, Model.manager adminModel)
        {
            Model.ReceiptPayDetail model = GetModel(id);
            if (model == null)
            {
                return("数据不存在");
            }
            string content = "";

            //3.如果是财务审批,要先验证部门审批是否已经审批通过,不通过不能审批;如果是总经理审批,要先验证财务审批是否已经审批通过,不通过不能审批
            //4.反审批时:a.总经理要先验证是否已经确认汇总。b.财务要先验证总经理是否已经审批通过。c.部门要先验证财务是否已经审批通过
            switch (type)
            {
            case 1:    //部门审批
                if (model.rpd_flag1 == status)
                {
                    return("状态未变更");
                }
                //判断有没有部门审批权限
                if (model.rpd_area != adminModel.area || !new permission().checkHasPermission(adminModel, "0603"))
                {
                    return("无权限审批");
                }
                if (status == 2)
                {
                    //由待审批、审批未通过→审批通过
                }
                else
                {
                    //由审批通过→待审批、审批未通过:验证财务审批是否通过,审批通过的不能再做部门反审批
                    if (model.rpd_flag2 == 2)
                    {
                        return("财务已经审批通过,不能做部门审批");
                    }
                }
                content                = "记录id:" + id + ",部门审批状态:" + Common.BusinessDict.checkStatus()[model.rpd_flag1] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>";
                model.rpd_flag1        = status;
                model.rpd_checkNum1    = adminModel.user_name;
                model.rpd_checkName1   = adminModel.real_name;
                model.rpd_checkRemark1 = remark;
                model.rpd_checkTime1   = DateTime.Now;
                break;

            case 2:    //财务审批
                if (model.rpd_flag2 == status)
                {
                    return("状态未改变");
                }
                if (new BLL.department().getGroupArea() != adminModel.area || !new permission().checkHasPermission(adminModel, "0402"))
                {
                    return("无权限审批");
                }
                if (status == 2)
                {
                    //由待审批、审批未通过→审批通过:验证部门审批是否存在待审批或审批未通过的记录,存在则不能做财务审批
                    if (model.rpd_flag1 != 2)
                    {
                        return("部门审批是待审批或审批未通过的,不能做财务审批");
                    }
                }
                else
                {
                    //由审批通过→待审批、审批未通过:验证总经理审批是否通过,审批通过的不能再做财务反审批
                    if (model.rpd_flag3 == 2)
                    {
                        return("总经理已经审批通过,不能做财务审批");
                    }
                }
                content                = "记录id:" + id + ",财务审批状态:" + Common.BusinessDict.checkStatus()[model.rpd_flag2] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>";
                model.rpd_flag2        = status;
                model.rpd_checkNum2    = adminModel.user_name;
                model.rpd_checkName2   = adminModel.real_name;
                model.rpd_checkRemark2 = remark;
                model.rpd_checkTime2   = DateTime.Now;
                break;

            case 3:    //总经理审批
                if (model.rpd_flag3 == status)
                {
                    return("状态未改变");
                }
                if (new BLL.department().getGroupArea() != adminModel.area || !new permission().checkHasPermission(adminModel, "0601"))
                {
                    return("无权限审批");
                }
                if (status == 2)
                {
                    //由待审批、审批未通过→审批通过:验证财务审批是否存在待审批或审批未通过的记录,存在则不能做总经理审批
                    if (model.rpd_flag2 != 2)
                    {
                        return("财务审批是待审批或审批未通过的,不能做总经理审批");
                    }
                }
                else
                {
                    //由审批通过→待审批、审批未通过:验证是否已经汇总,已经汇总的不能做总经理审批
                    if (model.rpd_rpid > 0)
                    {
                        return("已经汇总,不能做总经理审批");
                    }
                }
                content                = "记录id:" + id + ",总经理审批状态:" + Common.BusinessDict.checkStatus()[model.rpd_flag3] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>";
                model.rpd_flag3        = status;
                model.rpd_checkNum3    = adminModel.user_name;
                model.rpd_checkName3   = adminModel.real_name;
                model.rpd_checkRemark3 = remark;
                model.rpd_checkTime3   = DateTime.Now;
                break;
            }
            if (dal.Update(model))
            {
                //写日志
                Model.business_log log = new Model.business_log();
                log.ol_title    = "审批付款明细";
                log.ol_oid      = model.rpd_oid;
                log.ol_cid      = model.rpd_cid.Value;
                log.ol_relateID = id;
                string _content = content;
                log.ol_content = _content;
                new business_log().Add(DTEnums.ActionEnum.Audit.ToString(), log, adminModel.user_name, adminModel.real_name);

                //信息通知
                //审批未通过、审批通过时通知
                if (status == 1 || status == 2)
                {
                    string    replaceUser1   = "";
                    string    nodeName       = string.Empty;
                    DataTable dt             = null;
                    string    replaceContent = new BLL.Customer().GetModel(model.rpd_cid.Value).c_name + "," + model.rpd_money + "," + model.rpd_content + "," + model.rpd_oid;
                    string    replaceUser    = adminModel.user_name + "," + adminModel.real_name;
                    if (status == 1)
                    {
                        nodeName = "非业务付款通知部门审批、财务审批、总经理未通过";
                    }
                    else
                    {
                        if (type == 3)//总经理审批完成
                        {
                            nodeName = "非业务付款通知总经理审批通过";
                        }
                        else
                        {
                            nodeName = "非业务付款通知部门审批、财务审批通过";
                            if (type == 1)
                            {
                                dt = new manager().getUserByPermission("0402").Tables[0];
                            }
                            else
                            {
                                dt = new manager().getUserByPermission("0601").Tables[0];
                            }
                            if (dt != null)
                            {
                                foreach (DataRow dr in dt.Rows)
                                {
                                    replaceUser1 += dr["user_name"] + "(" + dr["real_name"] + "),";
                                }
                            }
                            replaceUser1 = replaceUser1.TrimEnd(',');
                        }
                    }
                    //钉钉通知申请人
                    Model.manager_oauth oauthModel = new BLL.manager_oauth().GetModel(model.rpd_personNum);
                    if (oauthModel != null && oauthModel.is_lock == 1 && !string.IsNullOrEmpty(oauthModel.oauth_userid))
                    {
                        new BLL.selfMessage().sentDingMessage(nodeName, oauthModel.oauth_userid, replaceContent, replaceUser);
                    }
                    //通知下付款通知人
                    new BLL.selfMessage().AddMessage(nodeName, model.rpd_personNum, model.rpd_personName, replaceContent, replaceUser, replaceUser1);

                    //通知下一级审批人
                    if (!string.IsNullOrEmpty(replaceUser1))
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            new BLL.selfMessage().AddMessage(nodeName, dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser, replaceUser1);

                            //钉钉推送通知
                            if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"])))
                            {
                                new BLL.selfMessage().sentDingMessage(nodeName, dr["oauth_userid"].ToString(), replaceContent, replaceUser, replaceUser1);
                            }
                        }
                    }
                }
                return("");
            }
            return("操作失败");
        }
Esempio n. 14
0
        /// <summary>
        /// 删除收付款明细
        /// </summary>
        public string Delete(int id, Model.manager manager)
        {
            Model.ReceiptPayDetail model = GetModel(id);
            if (model == null)
            {
                return("数据不存在");
            }
            Model.Order order = new BLL.Order().GetModel(model.rpd_oid);
            if (order == null)
            {
                return("订单不存在");
            }
            if (!new BLL.permission().checkHasPermission(manager, "0401"))//如果不是财务
            {
                //验证权限:在同一个订单里,业务员与业务报账员可以对未审核地接进行编辑与删除!执行人员只能对自己地址进行编辑与删除操作!
                if (model.rpd_personNum != manager.user_name && order.personlist.Where(p => p.op_number == manager.user_name && (p.op_type == 3 || p.op_type == 4)).ToArray().Length > 0)
                {
                    return("无权限删除");
                }
            }
            else
            {
                if (model.rpd_personNum != manager.user_name && !new BLL.permission().checkHasPermission(manager, "0403"))
                {
                    return("非申请人或没有删除他人数据权限不能删除");
                }
            }
            bool flag = false;

            if (model.rpd_type.Value)
            {
                if (model.rpd_rpid > 0)
                {
                    Model.ReceiptPay rp = new BLL.ReceiptPay().GetModel(model.rpd_rpid.Value);
                    if (rp.rp_isConfirm.Value)
                    {
                        return("已确认收款,不能再删除");
                    }
                }
                flag = dal.DeleteReceiptDetail(model);
            }
            else
            {
                if (model.rpd_flag3 == 2 && model.rpd_money >= 0)
                {
                    return("最终审批通过不能再编辑");
                }
                flag = dal.Delete(id);
                if (flag)
                {
                    //删除图片附件
                    new BLL.payPic().deleteFileByid(id, 1);
                }
            }

            string typeText = "收款";

            if (!model.rpd_type.Value)
            {
                typeText = "付款";
            }
            if (flag)
            {
                Model.business_log logmodel = new Model.business_log();
                logmodel.ol_oid         = model.rpd_oid;
                logmodel.ol_relateID    = model.rpd_id.Value;
                logmodel.ol_cid         = model.rpd_cid.Value;
                logmodel.ol_title       = "删除" + typeText + "明细";
                logmodel.ol_content     = "记录ID:" + id + ",金额:" + model.rpd_money + "";
                logmodel.ol_operateDate = DateTime.Now;
                new business_log().Add(DTEnums.ActionEnum.Delete.ToString(), logmodel, manager.user_name, manager.real_name); //记录日志
                return("");
            }
            return("删除失败");
        }
Esempio n. 15
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool UpdateReceiptDetail(Model.ReceiptPayDetail model, bool updateMoney)
 {
     return(dal.UpdateReceiptDetail(model, updateMoney));
 }
Esempio n. 16
0
        /// <summary>
        /// 编辑收付款明细
        /// </summary>
        /// <param name="model"></param>
        /// <param name="content"></param>
        /// <param name="manager"></param>
        /// <param name="updateMoney">是否修改了收款明细的金额</param>
        /// <returns></returns>
        public string Update(Model.ReceiptPayDetail model, string content, Model.manager manager, bool updateMoney = false, bool updateMethod = false)
        {
            if (model == null)
            {
                return("数据不存在");
            }
            Model.Order order = new BLL.Order().GetModel(model.rpd_oid);
            if (order == null)
            {
                return("订单不存在");
            }
            if (!new BLL.permission().checkHasPermission(manager, "0401"))//如果不是财务
            {
                //验证权限:在同一个订单里,业务员与业务报账员可以对未审核地接进行编辑与删除!执行人员只能对自己地址进行编辑与删除操作!
                if (model.rpd_personNum != manager.user_name && order.personlist.Where(p => p.op_number == manager.user_name && (p.op_type == 3 || p.op_type == 4)).ToArray().Length > 0)
                {
                    return("无权限编辑");
                }
            }
            else
            {
                if (model.rpd_personNum != manager.user_name && !new BLL.permission().checkHasPermission(manager, "0403"))
                {
                    return("无权限编辑");
                }
            }
            string typeText = "收款";

            if (!model.rpd_type.Value)
            {
                typeText = "付款";
            }

            if (model.rpd_cid == 0)
            {
                return("请选择" + typeText + "对象");
            }
            if (model.rpd_money == 0)
            {
                return("请填写" + typeText + "金额");
            }
            if (model.rpd_foredate == null)
            {
                return("请选择" + (model.rpd_type.Value ? "预收" : "预付") + "日期");
            }
            bool flag = false;

            if (model.rpd_type.Value)
            {
                if (model.rpd_method == 0)
                {
                    return("请选择收款方式");
                }
                if (model.rpd_rpid > 0)
                {
                    Model.ReceiptPay rp = new BLL.ReceiptPay().GetModel(model.rpd_rpid.Value);
                    if (rp.rp_isConfirm.Value)
                    {
                        return("已确认收款,不能再编辑");
                    }
                }
                flag = UpdateReceiptDetail(model, updateMoney);
            }
            else
            {
                if (updateMethod)
                {
                    if (model.rpd_rpid > 0)
                    {
                        return("已经汇总的不能修改付款方式");
                    }
                }
                else if (updateMoney)
                {
                    if (model.rpd_money >= 0)
                    {
                        model.rpd_flag1        = 0;
                        model.rpd_checkNum1    = "";
                        model.rpd_checkName1   = "";
                        model.rpd_checkRemark1 = "";
                        model.rpd_checkTime1   = null;
                        model.rpd_flag2        = 0;
                        model.rpd_checkNum2    = "";
                        model.rpd_checkName2   = "";
                        model.rpd_checkRemark2 = "";
                        model.rpd_checkTime2   = null;
                        model.rpd_flag3        = 0;
                        model.rpd_checkNum3    = "";
                        model.rpd_checkName3   = "";
                        model.rpd_checkRemark3 = "";
                        model.rpd_checkTime3   = null;
                    }
                    else
                    {
                        model.rpd_flag1      = 2;
                        model.rpd_checkTime1 = DateTime.Now;
                        model.rpd_flag2      = 2;
                        model.rpd_checkTime2 = DateTime.Now;
                        model.rpd_flag3      = 2;
                        model.rpd_checkTime3 = DateTime.Now;
                    }
                }
                else if (model.rpd_money >= 0 && model.rpd_flag1 == 2 && model.rpd_flag2 != 1 && model.rpd_flag3 != 1)
                {
                    return("部门审批已通过,不能再编辑");
                }
                //编辑后清空审批内容,如果只是修改付款方式则不需要情况 2020-05-30
                if ((model.rpd_flag1 == 1 || model.rpd_flag2 == 1 || model.rpd_flag3 == 1) && !updateMethod)
                {
                    model.rpd_flag1        = 0;
                    model.rpd_checkNum1    = "";
                    model.rpd_checkName1   = "";
                    model.rpd_checkRemark1 = "";
                    model.rpd_checkTime1   = null;
                    model.rpd_flag2        = 0;
                    model.rpd_checkNum2    = "";
                    model.rpd_checkName2   = "";
                    model.rpd_checkRemark2 = "";
                    model.rpd_checkTime2   = null;
                    model.rpd_flag3        = 0;
                    model.rpd_checkNum3    = "";
                    model.rpd_checkName3   = "";
                    model.rpd_checkRemark3 = "";
                    model.rpd_checkTime3   = null;
                }
                flag = dal.Update(model);
            }

            if (flag)
            {
                Model.business_log logmodel = new Model.business_log();
                logmodel.ol_oid         = model.rpd_oid;
                logmodel.ol_relateID    = model.rpd_id.Value;
                logmodel.ol_cid         = model.rpd_cid.Value;
                logmodel.ol_title       = "编辑" + typeText + "明细";
                logmodel.ol_content     = content.ToString();
                logmodel.ol_operateDate = DateTime.Now;
                new business_log().Add(DTEnums.ActionEnum.Edit.ToString(), logmodel, manager.user_name, manager.real_name); //记录日志

                //钉钉通知
                if (!model.rpd_type.Value && !string.IsNullOrEmpty(content))
                {
                    DataTable userDt = new BLL.manager().getUserByPermission("0603", model.rpd_area).Tables[0];
                    if (userDt != null)
                    {
                        string replaceContent = model.rpd_oid + "," + model.rpd_money + "," + model.rpd_content;
                        string replaceUser    = model.rpd_personNum + "," + model.rpd_personName;
                        foreach (DataRow dr in userDt.Rows)
                        {
                            //钉钉推送通知
                            if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"])))
                            {
                                new BLL.selfMessage().sentDingMessage("添加付款通知", dr["oauth_userid"].ToString(), replaceContent, replaceUser);
                            }
                        }
                    }
                }

                return("");
            }
            return("编辑失败");
        }
Esempio n. 17
0
        /// <summary>
        /// 修改收款明细
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateReceiptDetail(Model.ReceiptPayDetail model, bool updateMoney)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            //利用反射获得属性的所有公共属性
            PropertyInfo[]      pros  = model.GetType().GetProperties();
            List <SqlParameter> paras = new List <SqlParameter>();

            strSql.Append("update MS_ReceiptPayDetail set ");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("rpd_id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + "=@" + pi.Name + ",");                          //声明参数
                        paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(" where rpd_id=@id ");
            paras.Add(new SqlParameter("@id", model.rpd_id));
            bool result = false;

            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();//打开数据连接
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 修改收款明细======================
                        int obj = DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), paras.ToArray());
                        #endregion

                        #region 修改收款通知==========================
                        if (obj > 0)
                        {
                            string sql = "select count(*) from MS_ReceiptPayDetail where rpd_rpid=@rpid";
                            List <SqlParameter> paras0 = new List <SqlParameter>();
                            paras0.Add(new SqlParameter("@rpid", model.rpd_rpid));
                            int count = Convert.ToInt32(DbHelperSQL.GetSingle(conn, trans, sql, paras0.ToArray()));
                            if (count > 0)
                            {
                                if (count == 1)
                                {
                                    //只有一条明细时,把收款对象,收款内容,收款金额,预收日期,收款方式一并更新到收款通知
                                    sql = "update MS_ReceiptPay set rp_cid=@cid,rp_content=@content,rp_money=@money,rp_foredate=@foredate,rp_method=@method where rp_id=@rpid and rp_isConfirm=0";
                                    List <SqlParameter> paras1 = new List <SqlParameter>();
                                    paras1.Add(new SqlParameter("@cid", model.rpd_cid));
                                    paras1.Add(new SqlParameter("@content", model.rpd_content));
                                    paras1.Add(new SqlParameter("@money", model.rpd_money));
                                    paras1.Add(new SqlParameter("@foredate", model.rpd_foredate));
                                    paras1.Add(new SqlParameter("@method", model.rpd_method));
                                    paras1.Add(new SqlParameter("@rpid", model.rpd_rpid));
                                    DbHelperSQL.ExecuteSql(conn, trans, sql, paras1.ToArray());
                                }
                                else
                                {
                                    //有多条明细时,只变更总金额到收款通知
                                    if (updateMoney)
                                    {
                                        sql = "update MS_ReceiptPay set rp_money=(select SUM(rpd_money) from MS_ReceiptPayDetail where rpd_rpid=@rpid) where rp_id=@rpid and rp_isConfirm=0";
                                        DbHelperSQL.ExecuteSql(conn, trans, sql, paras0.ToArray());
                                    }
                                }
                            }
                            trans.Commit();
                            result = true;
                        }
                        #endregion
                    }
                    catch (Exception err)
                    {
                        trans.Rollback(); //回滚事务
                        result = false;
                    }
                }
            }
            return(result);
        }
Esempio n. 18
0
        /// <summary>
        /// 删除收款明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteReceiptDetail(Model.ReceiptPayDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from  MS_ReceiptPayDetail ");
            strSql.Append(" where rpd_id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.rpd_id;
            bool result = false;

            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();//打开数据连接
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        string sql = "select count(*) from MS_ReceiptPayDetail where rpd_rpid=@rpid";
                        List <SqlParameter> paras0 = new List <SqlParameter>();
                        paras0.Add(new SqlParameter("@rpid", model.rpd_rpid));
                        int count = Convert.ToInt32(DbHelperSQL.GetSingle(conn, trans, sql, paras0.ToArray()));

                        #region  除收款明细======================
                        int obj = DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters.ToArray());
                        #endregion

                        #region 修改收款通知==========================
                        if (obj > 0)
                        {
                            if (count > 0)
                            {
                                if (count == 1)
                                {
                                    //只有一条明细时,把收款通知删除
                                    sql = "delete from MS_ReceiptPay where rp_id=@rpid and rp_isConfirm=0";
                                    List <SqlParameter> paras1 = new List <SqlParameter>();
                                    paras1.Add(new SqlParameter("@rpid", model.rpd_rpid));
                                    DbHelperSQL.ExecuteSql(conn, trans, sql, paras1.ToArray());
                                }
                                else
                                {
                                    //有多条明细时,只变更总金额到收款通知
                                    sql = "update MS_ReceiptPay set rp_money=(select SUM(rpd_money) from MS_ReceiptPayDetail where rpd_rpid=@rpid) where rp_id=@rpid and rp_isConfirm=0";
                                    DbHelperSQL.ExecuteSql(conn, trans, sql, paras0.ToArray());
                                }
                            }
                            trans.Commit();
                            result = true;
                        }
                        #endregion
                    }
                    catch (Exception err)
                    {
                        trans.Rollback(); //回滚事务
                        result = false;
                    }
                }
            }
            return(result);
        }