private void ShowInfo(int _id) { BLL.certificates bll = new BLL.certificates(); Model.certificates model = bll.GetModel(_id); txtNum.Text = model.ce_num; txtDate.Text = model.ce_date.Value.ToString("yyyy-MM-dd"); txtRemark.Text = model.ce_remark; }
/// <summary> /// 取消标记凭证 /// </summary> /// <param name="id"></param> /// <param name="username"></param> /// <param name="realname"></param> /// <returns></returns> public string cancelSignCertificate(int id, Model.manager manager) { if (new BLL.department().getGroupArea() != manager.area || (!new permission().checkHasPermission(manager, "0404") && !new permission().checkHasPermission(manager, "0406"))) { return("无权限取消标记"); } Model.ReceiptPay rp = GetModel(id); if (rp == null) { return("记录不存在"); } int ceid = 0; int.TryParse(rp.rp_ceid.ToString(), out ceid); if (ceid == 0) { return("还未标记凭证的不能取消"); } Model.certificates model = new BLL.certificates().GetModel(ceid); if (model == null) { return("凭证不存在"); } if (model.ce_flag == 2) { return("凭证已经审批通过,不能取消"); } rp.rp_ceid = 0; if (dal.Update(rp)) { Model.business_log logmodel = new Model.business_log(); logmodel.ol_relateID = id; logmodel.ol_cid = rp.rp_cid.Value; logmodel.ol_title = "取消标记凭证"; logmodel.ol_content = "凭证号:" + model.ce_num + "<br/>凭证日期:" + model.ce_date.Value.ToString("yyyy-MM-dd"); logmodel.ol_operateDate = DateTime.Now; new business_log().Add(DTEnums.ActionEnum.Sign.ToString(), logmodel, manager.user_name, manager.real_name); return(""); } return("标记失败"); }
private string DoAdd() { Model.certificates model = new Model.certificates(); BLL.certificates bll = new BLL.certificates(); manager = GetAdminInfo(); model.ce_num = txtNum.Text.Trim(); model.ce_date = ConvertHelper.toDate(txtDate.Text.Trim()); model.ce_remark = txtRemark.Text.Trim(); model.ce_personNum = manager.user_name; model.ce_personName = manager.real_name; int _naid = 0; string result = bll.Add(model, out _naid); if (_naid > 0) { return(""); } return("添加失败"); }
private string DoEdit(int _id) { BLL.certificates bll = new BLL.certificates(); Model.certificates model = bll.GetModel(_id); if (model.ce_flag == 2) { return("凭证号已经审批通过,不能编辑"); } if (string.IsNullOrEmpty(txtNum.Text.Trim())) { return("请填写凭证号"); } if (string.IsNullOrEmpty(txtDate.Text.Trim())) { return("请填写凭证日期"); } string _content = string.Empty; bool _update = false; if (model.ce_num != txtNum.Text.Trim()) { _update = true; _content += "凭证号:" + model.ce_num + "→<font color='red'>" + txtNum.Text.Trim() + "</font><br/>"; } model.ce_num = txtNum.Text.Trim(); if (model.ce_date != Convert.ToDateTime(txtDate.Text.Trim())) { _update = true; _content += "凭证日期:" + model.ce_date.Value.ToString("yyyy-MM-dd") + "→<font color='red'>" + txtNum.Text.Trim() + "</font><br/>"; } model.ce_date = Convert.ToDateTime(txtDate.Text.Trim()); if (_update) { //判断是否被使用 DataSet ds = new BLL.ReceiptPay().GetList(0, "rp_ceid=" + id, ""); if (ds != null && ds.Tables[0].Rows.Count > 0) { return("该凭证已被使用,不能修改凭证号和凭证日期,只能修改备注"); } } if (model.ce_remark != txtRemark.Text.Trim()) { _content += "备注:" + model.ce_remark + "→<font color='red'>" + txtRemark.Text.Trim() + "</font><br/>"; } model.ce_remark = txtRemark.Text.Trim(); if (bll.Exists(model.ce_num, model.ce_date, _id)) { return("凭证号、凭证日期重复"); } if (bll.Update(model)) { if (!string.IsNullOrEmpty(_content)) { logmodel = new Model.business_log(); logmodel.ol_relateID = _id; logmodel.ol_title = "修改凭证"; logmodel.ol_content = _content; logmodel.ol_operateDate = DateTime.Now; AddBusinessLog(DTEnums.ActionEnum.Edit.ToString(), logmodel); //记录日志 } return(""); } return("修改失败"); }
/// <summary> /// 标记凭证 /// </summary> /// <param name="id"></param> /// <param name="num"></param> /// <param name="date"></param> /// <param name="username"></param> /// <param name="realname"></param> /// <returns></returns> public string signCertificate(int id, string num, string date, Model.manager manager) { if (new BLL.department().getGroupArea() != manager.area || (!new permission().checkHasPermission(manager, "0404") && !new permission().checkHasPermission(manager, "0406"))) { return("无权限标记"); } Model.certificates model = new BLL.certificates().GetModel(num, Convert.ToDateTime(date)); int ceid = 0; if (model == null) { Model.certificates cemodel = new Model.certificates(); cemodel.ce_num = num; cemodel.ce_date = ConvertHelper.toDate(date); cemodel.ce_personNum = manager.user_name; cemodel.ce_personName = manager.real_name; new BLL.certificates().Add(cemodel, out ceid); if (ceid > 0) { cemodel.ce_id = ceid; model = cemodel; } } else { ceid = model.ce_id.Value; } if (model.ce_flag == 2) { return("凭证号和凭证日期已经审批通过,不能使用"); } Model.ReceiptPay rp = GetModel(id); if (rp == null) { return("记录不存在"); } string text = "收款"; if (!rp.rp_type.Value) { text = "付款"; } if (!rp.rp_isConfirm.Value) { return("必须确认" + text + "后才能标记凭证"); } //如果已经存在凭证,且该凭证已经审核通过,则不能标记新凭证 if (rp.rp_ceid > 0) { Model.certificates oldcert = new BLL.certificates().GetModel(rp.rp_ceid.Value); if (oldcert.ce_flag == 2) { return("前面标记的凭证已经审核通过,不能再标记新的凭证"); } } rp.rp_ceid = ceid; if (dal.Update(rp)) { Model.business_log logmodel = new Model.business_log(); logmodel.ol_relateID = id; logmodel.ol_cid = rp.rp_cid.Value; logmodel.ol_title = "标记凭证"; logmodel.ol_content = "凭证号:" + num + "<br/>凭证日期:" + date; logmodel.ol_operateDate = DateTime.Now; new business_log().Add(DTEnums.ActionEnum.Sign.ToString(), logmodel, manager.user_name, manager.real_name); return(""); } return("标记失败"); }
/// <summary> /// 增加一条数据 /// </summary> public string Add(Model.ReceiptPay model, Model.manager manager, string num, string date, out int rpid, bool flag = true) { rpid = 0; string typeText = "收款"; if (!model.rp_type.Value) { typeText = "付款"; } if (flag) { model.rp_isExpect = true; } else { model.rp_isExpect = false; } if (model.rp_isExpect.Value && !new BLL.permission().checkHasPermission(manager, "0406")) { return("无权限添加"); } if (model.rp_cid == 0) { return("请选择" + typeText + "对象"); } if (model.rp_money == 0) { return("请填写" + typeText + "金额"); } if (model.rp_foredate == null) { return("请选择" + (model.rp_type.Value?"预收":"预付") + "日期"); } //预收款的收款方式是必填的,预付款的付款方式是非必填的 if (model.rp_type.Value && model.rp_method == 0) { return("请选择" + typeText + "方式"); } else { if (model.rp_method != 0) { Model.payMethod method = new BLL.payMethod().GetModel(model.rp_method.Value); if (method.pm_type.Value) { model.rp_cbid = 0; if (string.IsNullOrEmpty(num)) { return("请填写凭证号"); } if (string.IsNullOrEmpty(date)) { return("请填写凭证日期"); } Model.certificates ce = new BLL.certificates().GetModel(num, Convert.ToDateTime(date)); int ceid = 0; if (ce == null) { Model.certificates cemodel = new Model.certificates(); cemodel.ce_num = num; cemodel.ce_date = ConvertHelper.toDate(date); cemodel.ce_personNum = manager.user_name; cemodel.ce_personName = manager.real_name; new BLL.certificates().Add(cemodel, out ceid); if (ceid > 0) { cemodel.ce_id = ceid; } } else { ceid = ce.ce_id.Value; } model.rp_ceid = ceid; } else { if (model.rp_cbid == 0 && model.rp_money < 0) { return("请选择客户银行账号"); } } } else { if (model.rp_cbid == 0) { return("请选择客户银行账号"); } } } model.rp_isConfirm = false; bool isChongzhang = false; if (model.rp_type.Value) { model.rp_flag = 0; model.rp_flag1 = 0; if (model.rp_money >= 0) { model.rp_flag = 2; model.rp_checkTime = DateTime.Now; model.rp_flag1 = 2; model.rp_checkTime1 = DateTime.Now; isChongzhang = model.rp_method.Value > 0 && new BLL.payMethod().GetModel(model.rp_method.Value).pm_type.Value; if (isChongzhang) { model.rp_isConfirm = true; model.rp_date = model.rp_foredate; model.rp_confirmerName = manager.real_name; model.rp_confirmerNum = manager.user_name; } } else { isChongzhang = model.rp_method.Value > 0 && new BLL.payMethod().GetModel(model.rp_method.Value).pm_type.Value; if (isChongzhang) { model.rp_flag = 2; model.rp_checkTime = DateTime.Now; model.rp_flag1 = 2; model.rp_checkTime1 = DateTime.Now; model.rp_isConfirm = true; model.rp_date = model.rp_foredate; model.rp_confirmerName = manager.real_name; model.rp_confirmerNum = manager.user_name; } else { if (model.rp_cbid == 0) { return("请选择客户银行账号"); } } } } else { model.rp_isExpect = true; model.rp_flag = 0; model.rp_flag1 = 0; isChongzhang = model.rp_method.Value > 0 && new BLL.payMethod().GetModel(model.rp_method.Value).pm_type.Value; if (isChongzhang || model.rp_money < 0) { model.rp_flag = 2; model.rp_checkTime = DateTime.Now; model.rp_flag1 = 2; model.rp_checkTime1 = DateTime.Now; model.rp_isConfirm = true; model.rp_date = model.rp_foredate; model.rp_confirmerName = manager.real_name; model.rp_confirmerNum = manager.user_name; } } model.rp_personNum = manager.user_name; model.rp_personName = manager.real_name; model.rp_adddate = DateTime.Now; model.rp_area = manager.area; rpid = dal.Add(model); if (rpid > 0) { StringBuilder content = new StringBuilder(); content.Append("" + typeText + "对象ID:" + model.rp_cid + "<br/>"); content.Append("预收款:是<br/>"); content.Append("" + typeText + "金额:" + model.rp_money + "<br/>"); content.Append("" + (model.rp_type.Value ? "预收" : "预付") + "日期:" + model.rp_foredate.Value.ToString("yyyy-MM-dd") + "<br/>"); content.Append("收款方式ID:" + model.rp_method + "<br/>"); content.Append("收款内容:" + model.rp_content + "<br/>"); content.Append("客户银行账号:" + model.rp_cbid + "<br/>"); Model.business_log logmodel = new Model.business_log(); logmodel.ol_relateID = rpid; logmodel.ol_cid = model.rp_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.rp_type.Value && model.rp_money >= 0 && (model.rp_method == 0 || !isChongzhang)) { DataTable userDt = new BLL.manager().getUserByPermission("0402").Tables[0]; if (userDt != null) { string replaceContent = model.rp_money + "," + model.rp_content; string replaceUser = model.rp_personNum + "," + model.rp_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); } } } } //退款订单通知 if (model.rp_type.Value && model.rp_money < 0 && !isChongzhang) { DataTable userDt = new BLL.manager().getUserByPermission("0402").Tables[0]; if (userDt != null) { string replaceContent = model.rp_money + "," + model.rp_content; string replaceUser = model.rp_personNum + "," + model.rp_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("添加失败"); }
/// <summary> /// 更新一条数据 /// </summary> public string Update(Model.ReceiptPay model, string content, Model.manager manager, string num, string date, bool updateMoney = false) { if (!new BLL.permission().checkHasPermission(manager, "0401"))//如果不是财务 { return("无权限编辑"); } else { if (model.rp_personNum != manager.user_name && !new BLL.permission().checkHasPermission(manager, "0403")) { return("无权限编辑"); } } string typeText = "收款"; if (model.rp_type.Value) { if (model.rp_isConfirm.Value) { return("已经确认收款,不能再编辑"); } } else { typeText = "付款"; if (updateMoney) { if (model.rp_money < 0) { model.rp_flag = 2; model.rp_checkTime = DateTime.Now; model.rp_flag1 = 2; model.rp_checkTime1 = DateTime.Now; model.rp_isConfirm = true; model.rp_date = model.rp_foredate; model.rp_confirmerName = manager.real_name; model.rp_confirmerNum = manager.user_name; } else { model.rp_flag = 0; model.rp_checkNum = ""; model.rp_checkName = ""; model.rp_checkRemark = ""; model.rp_checkTime = null; model.rp_flag1 = 0; model.rp_checkNum1 = ""; model.rp_checkName1 = ""; model.rp_checkRemark1 = ""; model.rp_checkTime1 = null; model.rp_isConfirm = false; } } else { if (model.rp_money >= 0 && model.rp_flag == 2 && model.rp_flag1 != 1 && !new BLL.payMethod().GetModel(model.rp_method.Value).pm_type.Value) { return("财务已经审批通过,不能再编辑"); } if (model.rp_flag == 1 || model.rp_flag1 == 1) { model.rp_flag = 0; model.rp_checkNum = ""; model.rp_checkName = ""; model.rp_checkRemark = ""; model.rp_checkTime = null; model.rp_flag1 = 0; model.rp_checkNum1 = ""; model.rp_checkName1 = ""; model.rp_checkRemark1 = ""; model.rp_checkTime1 = null; } } } if (model.rp_cid == 0) { return("请选择" + typeText + "对象"); } if (model.rp_money == 0) { return("请填写" + typeText + "金额"); } if (model.rp_foredate == null) { return("请选择" + (model.rp_type.Value ? "预收" : "预付") + "日期"); } if (model.rp_type.Value && model.rp_method == 0) { return("请选择" + typeText + "方式"); } else { if (model.rp_method != 0) { Model.payMethod method = new BLL.payMethod().GetModel(model.rp_method.Value); if (method.pm_type.Value) { model.rp_cbid = 0; if (string.IsNullOrEmpty(num)) { return("请填写凭证号"); } if (string.IsNullOrEmpty(date)) { return("请填写凭证日期"); } Model.certificates ce = new BLL.certificates().GetModel(num, Convert.ToDateTime(date)); int ceid = 0; if (ce == null) { Model.certificates cemodel = new Model.certificates(); cemodel.ce_num = num; cemodel.ce_date = ConvertHelper.toDate(date); cemodel.ce_personNum = manager.user_name; cemodel.ce_personName = manager.real_name; new BLL.certificates().Add(cemodel, out ceid); if (ceid > 0) { cemodel.ce_id = ceid; } } else { ceid = ce.ce_id.Value; } model.rp_ceid = ceid; } else { model.rp_ceid = 0; if (model.rp_cbid == 0) { return("请选择客户银行账号"); } } } else { if (model.rp_cbid == 0) { return("请选择客户银行账号"); } } } if (dal.Update(model)) { Model.business_log logmodel = new Model.business_log(); logmodel.ol_relateID = model.rp_id.Value; logmodel.ol_cid = model.rp_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.rp_type.Value) { DataTable userDt = new BLL.manager().getUserByPermission("0402").Tables[0]; if (userDt != null) { string replaceContent = model.rp_money + "," + model.rp_content; string replaceUser = model.rp_personNum + "," + model.rp_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("编辑失败"); }