/// <summary> /// 得到一个对象实体 /// </summary> public Model.invoices GetModel(int id) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); Model.invoices model = new Model.invoices(); //利用反射获得属性的所有公共属性 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_invoices"); strSql.Append(" where inv_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); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.invoices model) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); //利用反射获得属性的所有公共属性 PropertyInfo[] pros = model.GetType().GetProperties(); List <SqlParameter> paras = new List <SqlParameter>(); strSql.Append("update MS_invoices set "); foreach (PropertyInfo pi in pros) { //如果不是主键则追加sql字符串 if (!pi.Name.Equals("inv_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 inv_id=@id "); paras.Add(new SqlParameter("@id", model.inv_id)); return(DbHelperSQL.ExecuteSql(strSql.ToString(), paras.ToArray()) > 0); }
/// <summary> /// 开票 /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <param name="username"></param> /// <param name="realname"></param> /// <returns></returns> public string confirmInvoice(int id, bool?status, string date, Model.manager adminModel) { if (status.Value && string.IsNullOrEmpty(date)) { return("请填写开票日期"); } Model.invoices model = GetModel(id); if (model == null) { return("数据不存在"); } if (model.inv_isConfirm == status) { return("状态未变更"); } if (model.inv_flag3 != 2) { return("财务审批未通过,不能开票"); } if (!new permission().checkHasPermission(adminModel, "0408")) { return("无权限开票"); } string _content = "发票id:" + id + ",开票状态:" + Common.BusinessDict.invoiceConfirmStatus()[model.inv_isConfirm] + "→<font color='red'>" + Common.BusinessDict.invoiceConfirmStatus()[status] + "</font>,开票日期:" + date; if (dal.confirmInvoice(id, status, ConvertHelper.toDate(date), adminModel.user_name, adminModel.real_name)) { //写日志 Model.business_log log = new Model.business_log(); log.ol_title = "发票开票"; log.ol_oid = model.inv_oid; log.ol_cid = model.inv_cid.Value; log.ol_relateID = id; log.ol_content = _content; new business_log().Add(DTEnums.ActionEnum.Audit.ToString(), log, adminModel.user_name, adminModel.real_name); //信息通知下申请通知人、业务员 if (status.Value) { string replaceContent = new BLL.Customer().GetModel(model.inv_cid.Value).c_name + "," + model.inv_money; string replaceUser = adminModel.user_name + "," + adminModel.real_name; new BLL.selfMessage().AddMessage("开票申请财务已开具", model.inv_personNum, model.inv_personName, replaceContent, replaceUser); //通知业务员 DataSet ds = new BLL.Order().GetPersonList(0, "op_oid='" + model.inv_oid + "' and op_type=1", ""); if (ds != null && ds.Tables[0].Rows.Count > 0) { new BLL.selfMessage().AddMessage("开票申请财务已开具", ds.Tables[0].Rows[0]["op_number"].ToString(), ds.Tables[0].Rows[0]["op_name"].ToString(), replaceContent, replaceUser); } } return(""); } return("操作失败"); }
/// <summary> /// 删除一条数据 /// </summary> public string Delete(int id, Model.manager manager) { Model.invoices model = GetModel(id); if (model == null) { return("数据不存在"); } if (model.inv_flag3 == 2) { return("最终审批通过不能再编辑"); } Model.Order order = new BLL.Order().GetModel(model.inv_oid); if (order == null) { return("订单不存在"); } if (!new BLL.permission().checkHasPermission(manager, "0401"))//如果不是财务 { //验证权限:在同一个订单里,业务员与业务报账员可以对未审核地接进行编辑与删除!执行人员只能对自己地址进行编辑与删除操作! if (model.inv_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.inv_personNum != manager.user_name && !new BLL.permission().checkHasPermission(manager, "0403")) { return("非申请人或没有删除他人数据权限不能删除"); } } if (dal.Delete(id)) { StringBuilder content = new StringBuilder(); content.Append("购买方名称:" + model.inv_purchaserName + "<br/>"); content.Append("购买方账号:" + model.inv_purchaserBankNum + "<br/>"); content.Append("金额:" + model.inv_money + "<br/>"); content.Append("应税劳务、服务名称:" + model.inv_serviceType + "," + model.inv_serviceName + "<br/>"); content.Append("送票方式:" + model.inv_sentWay + "<br/>"); content.Append("开票区域:" + model.inv_darea + "<br/>"); Model.business_log logmodel = new Model.business_log(); logmodel.ol_relateID = model.inv_id.Value; logmodel.ol_oid = model.inv_oid; logmodel.ol_cid = model.inv_cid.Value; logmodel.ol_title = "删除发票"; logmodel.ol_content = content.ToString(); logmodel.ol_operateDate = DateTime.Now; new business_log().Add(DTEnums.ActionEnum.Delete.ToString(), logmodel, manager.user_name, manager.real_name); //记录日志 return(""); } return("删除失败"); }
private string DoAdd() { Model.invoices model = new Model.invoices(); BLL.invoices bll = new BLL.invoices(); manager = GetAdminInfo(); model.inv_oid = oID; model.inv_cid = Utils.StrToInt(Request["hCusId"], 0); if (string.IsNullOrEmpty(ddlinvType.SelectedValue)) { return("请选择专普票类型"); } model.inv_type = ddlinvType.SelectedValue; model.inv_purchaserName = txtpurchaserName.Text.Trim(); model.inv_purchaserNum = txtpurchaserNum.Text.Trim(); model.inv_purchaserAddress = txtpurchaserAddress.Text.Trim(); model.inv_purchaserPhone = txtpurchaserPhone.Text.Trim(); model.inv_purchaserBank = txtpurchaserBank.Text.Trim(); model.inv_purchaserBankNum = txtpurchaserBankNum.Text.Trim(); model.inv_serviceType = ddlserviceType.SelectedItem.Text; if (ddlserviceType.SelectedValue == "4") { model.inv_serviceName = txtserviceName.Text; } else { model.inv_serviceName = ddlserviceName.SelectedItem.Text; } model.inv_money = Utils.StrToDecimal(txtmoney.Text.Trim(), 0); model.inv_sentWay = ddlsentWay.SelectedItem.Text; model.inv_farea = manager.area; model.inv_darea = ddldarea.SelectedValue; model.inv_unit = Utils.StrToInt(ddlunit.SelectedValue, 0); model.inv_receiveName = txtreceiveName.Text.Trim(); model.inv_receivePhone = txtreceivePhone.Text.Trim(); model.inv_receiveAddress = txtreceiveAddress.Text.Trim(); model.inv_remark = txtremark.Text.Trim(); model.inv_personName = manager.real_name; model.inv_personNum = manager.user_name; model.inv_addDate = DateTime.Now; model.inv_flag1 = 0; model.inv_flag2 = 0; model.inv_flag3 = 0; model.inv_isConfirm = false; return(bll.Add(model, manager)); }
/// <summary> /// 将对象转换实体 /// </summary> public Model.invoices DataRowToModel(DataRow row) { Model.invoices model = new Model.invoices(); 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); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.invoices model) { 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_invoices("); foreach (PropertyInfo pi in pros) { //如果不是主键则追加sql字符串 if (!pi.Name.Equals("inv_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 = DbHelperSQL.GetSingle(strSql.ToString(), paras.ToArray()); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private string DoEdit(int _id) { BLL.invoices bll = new BLL.invoices(); Model.invoices model = bll.GetModel(_id); manager = GetAdminInfo(); string _content = ""; if (model.inv_purchaserName != txtpurchaserName.Text.Trim()) { _content += "购买方名称:" + model.inv_purchaserName + "→<font color='red'>" + txtpurchaserName.Text.Trim() + "</font><br/>"; } model.inv_purchaserName = txtpurchaserName.Text.Trim(); if (model.inv_purchaserNum != txtpurchaserNum.Text.Trim()) { _content += "购买方纳税人识别号:" + model.inv_purchaserNum + "→<font color='red'>" + txtpurchaserNum.Text.Trim() + "</font><br/>"; } model.inv_purchaserNum = txtpurchaserNum.Text.Trim(); if (model.inv_purchaserAddress != txtpurchaserAddress.Text.Trim()) { _content += "购买方纳税人识别号:" + model.inv_purchaserAddress + "→<font color='red'>" + txtpurchaserAddress.Text.Trim() + "</font><br/>"; } model.inv_purchaserAddress = txtpurchaserAddress.Text.Trim(); if (model.inv_purchaserPhone != txtpurchaserPhone.Text.Trim()) { _content += "购买方地址:" + model.inv_purchaserPhone + "→<font color='red'>" + txtpurchaserPhone.Text.Trim() + "</font><br/>"; } model.inv_purchaserPhone = txtpurchaserPhone.Text.Trim(); if (model.inv_purchaserBank != txtpurchaserBank.Text.Trim()) { _content += "购买方电话:" + model.inv_purchaserBank + "→<font color='red'>" + txtpurchaserBank.Text.Trim() + "</font><br/>"; } model.inv_purchaserBank = txtpurchaserBank.Text.Trim(); if (model.inv_purchaserBankNum != txtpurchaserBankNum.Text.Trim()) { _content += "购买方开户行:" + model.inv_purchaserBankNum + "→<font color='red'>" + txtpurchaserBankNum.Text.Trim() + "</font><br/>"; } model.inv_purchaserBankNum = txtpurchaserBankNum.Text.Trim(); if (model.inv_serviceType != ddlserviceType.SelectedItem.Text) { _content += "应税劳务:" + model.inv_serviceType + "→<font color='red'>" + ddlserviceType.SelectedItem.Text + "</font><br/>"; } model.inv_serviceType = ddlserviceType.SelectedItem.Text; if (ddlserviceType.SelectedValue == "4") { if (model.inv_serviceName != txtserviceName.Text) { _content += "服务名称:" + model.inv_serviceName + "→<font color='red'>" + txtserviceName.Text + "</font><br/>"; } model.inv_serviceName = txtserviceName.Text; } else { if (model.inv_serviceName != ddlserviceName.SelectedItem.Text) { _content += "服务名称:" + model.inv_serviceName + "→<font color='red'>" + ddlserviceName.SelectedItem.Text + "</font><br/>"; } model.inv_serviceName = ddlserviceName.SelectedItem.Text; } if (string.IsNullOrEmpty(ddlinvType.SelectedValue)) { return("请选择发票类型"); } if (model.inv_type != ddlinvType.SelectedValue) { _content += "发票类型:" + model.inv_type + "→<font color='red'>" + ddlinvType.SelectedValue + "</font><br/>"; } model.inv_type = ddlinvType.SelectedValue; decimal _money = 0; if (!decimal.TryParse(txtmoney.Text.Trim(), out _money)) { return("请正确填写开票金额"); } if (model.inv_money != _money) { _content += "开票金额:" + model.inv_money + "→<font color='red'>" + _money + "</font><br/>"; } model.inv_money = _money; if (model.inv_sentWay != ddlsentWay.SelectedItem.Text) { _content += "送票方式:" + model.inv_sentWay + "→<font color='red'>" + ddlsentWay.SelectedItem.Text + "</font><br/>"; } model.inv_sentWay = ddlsentWay.SelectedItem.Text; if (model.inv_darea != ddldarea.SelectedValue) { _content += "开票区域:" + model.inv_darea + "→<font color='red'>" + ddldarea.SelectedValue + "</font><br/>"; } model.inv_darea = ddldarea.SelectedValue; if (model.inv_unit != Utils.StrToInt(ddlunit.SelectedValue, 0)) { _content += "开票单位:" + model.inv_unit + "→<font color='red'>" + ddlunit.SelectedValue + "</font><br/>"; } model.inv_unit = Utils.StrToInt(ddlunit.SelectedValue, 0); if (model.inv_receiveName != txtreceiveName.Text.Trim()) { _content += "收票人名称:" + model.inv_receiveName + "→<font color='red'>" + txtreceiveName.Text.Trim() + "</font><br/>"; } model.inv_receiveName = txtreceiveName.Text.Trim(); if (model.inv_receivePhone != txtreceivePhone.Text.Trim()) { _content += "收票人电话:" + model.inv_receivePhone + "→<font color='red'>" + txtreceivePhone.Text.Trim() + "</font><br/>"; } model.inv_receivePhone = txtreceivePhone.Text.Trim(); if (model.inv_receiveAddress != txtreceiveAddress.Text.Trim()) { _content += "收票人地址:" + model.inv_receiveAddress + "→<font color='red'>" + txtreceiveAddress.Text.Trim() + "</font><br/>"; } model.inv_receiveAddress = txtreceiveAddress.Text.Trim(); if (model.inv_remark != txtremark.Text.Trim()) { _content += "备注:" + model.inv_remark + "→<font color='red'>" + txtremark.Text.Trim() + "</font><br/>"; } model.inv_remark = txtremark.Text.Trim(); return(bll.Update(model, _content, manager)); }
/// <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 checkInvoiceStatus(int id, byte?type, byte?status, string remark, Model.manager adminModel) { Model.invoices model = GetModel(id); if (model == null) { return("数据不存在"); } string content = ""; //3.如果是开票区域审批,要先验证申请区域审批是否已经审批通过,不通过不能审批;如果是财务审批,要先验证开票区域审批是否已经审批通过,不通过不能审批 //4.反审批时:a.财务要先验证是否已经开票。b.开票区域要先验证财务是否已经审批通过。c.申请区域要先验证开票区域是否已经审批通过 switch (type) { case 1: //申请区域审批 if (model.inv_flag1 == status) { return("状态未变更"); } //判断有没有部门审批权限 if (model.inv_farea != adminModel.area || !new permission().checkHasPermission(adminModel, "0603")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过 //当申请区域和开票区域相同时,申请区域审批通过时,同时把开票区域审批通过 if (model.inv_farea == model.inv_darea) { model.inv_flag2 = status; model.inv_checkNum2 = adminModel.user_name; model.inv_checkName2 = adminModel.real_name; model.inv_checkRemark2 = remark; model.inv_checkTime2 = DateTime.Now; } } else { //由审批通过→待审批、审批未通过:验证开票区域审批是否通过,审批通过的不能再做申请区域反审批 if (model.inv_flag2 == 2) { return("开票区域已经审批通过,不能做申请区域审批"); } } content = "记录id:" + id + ",申请区域审批状态:" + Common.BusinessDict.checkStatus()[model.inv_flag1] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.inv_flag1 = status; model.inv_checkNum1 = adminModel.user_name; model.inv_checkName1 = adminModel.real_name; model.inv_checkRemark1 = remark; model.inv_checkTime1 = DateTime.Now; break; case 2: //开票区域审批 if (model.inv_flag2 == status) { return("状态未变更"); } //判断有没有部门审批权限 if (model.inv_darea != adminModel.area || !new permission().checkHasPermission(adminModel, "0603")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过:验证申请区域审批是否存在待审批或审批未通过的记录,存在则不能做开票区域审批 if (model.inv_flag1 != 2) { return("申请区域审批是待审批或审批未通过的,不能做开票区域审批"); } } else { //由审批通过→待审批、审批未通过:验证财务审批是否通过,审批通过的不能再做开票区域反审批 if (model.inv_flag3 == 2) { return("财务已经审批通过的,不能做开票区域审批"); } //当申请区域和开票区域相同时,开票区域反审批时,同时把申请区域反审批 if (model.inv_farea == model.inv_darea) { model.inv_flag1 = status; model.inv_checkNum1 = adminModel.user_name; model.inv_checkName1 = adminModel.real_name; model.inv_checkRemark1 = remark; model.inv_checkTime1 = DateTime.Now; } } content = "记录id:" + id + ",开票区域审批状态:" + Common.BusinessDict.checkStatus()[model.inv_flag2] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.inv_flag2 = status; model.inv_checkNum2 = adminModel.user_name; model.inv_checkName2 = adminModel.real_name; model.inv_checkRemark2 = remark; model.inv_checkTime2 = DateTime.Now; break; case 3: //财务审批 if (model.inv_flag3 == status) { return("状态未改变"); } if (new BLL.department().getGroupArea() != adminModel.area || !new permission().checkHasPermission(adminModel, "0402")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过:验证开票区域审批是否存在待审批或审批未通过的记录,存在则不能做财务审批 if (model.inv_flag2 != 2) { return("开票区域审批是待审批或审批未通过的,不能做财务审批"); } } else { //由审批通过→待审批、审批未通过:验证是否已经开票,已经开票的不能做财务审批 if (model.inv_isConfirm.Value) { return("已经开票,不能做财务审批"); } } content = "记录id:" + id + ",开票区域审批状态:" + Common.BusinessDict.checkStatus()[model.inv_flag3] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.inv_flag3 = status; model.inv_checkNum3 = adminModel.user_name; model.inv_checkName3 = adminModel.real_name; model.inv_checkRemark3 = remark; model.inv_checkTime3 = DateTime.Now; break; } if (dal.Update(model)) { //写日志 Model.business_log log = new Model.business_log(); log.ol_title = "审批发票申请"; log.ol_oid = model.inv_oid; log.ol_cid = model.inv_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) { string replaceContent = new BLL.Customer().GetModel(model.inv_cid.Value).c_name + "," + model.inv_money; string replaceUser = adminModel.user_name + "," + adminModel.real_name; new BLL.selfMessage().AddMessage("开票申请审批未通过", model.inv_personNum, model.inv_personName, replaceContent, replaceUser); //通知业务员 DataSet ds = new BLL.Order().GetPersonList(0, "op_oid='" + model.inv_oid + "' and op_type=1", ""); if (ds != null && ds.Tables[0].Rows.Count > 0) { new BLL.selfMessage().AddMessage("开票申请审批未通过", ds.Tables[0].Rows[0]["op_number"].ToString(), ds.Tables[0].Rows[0]["op_name"].ToString(), replaceContent, replaceUser); } //钉钉通知申请人 Model.manager_oauth oauthModel = new BLL.manager_oauth().GetModel(model.inv_personNum); if (oauthModel != null && oauthModel.is_lock == 1 && !string.IsNullOrEmpty(oauthModel.oauth_userid)) { new BLL.selfMessage().sentDingMessage("发票申请审批未通过", oauthModel.oauth_userid, replaceContent, replaceUser); } } //信息通知下申请通知人、业务员,如果是申请区域审批和开票区域审批 要通知下一级审批人 if (status == 2) { string replaceContent = new BLL.Customer().GetModel(model.inv_cid.Value).c_name + "," + model.inv_money; string replaceUser = adminModel.user_name + "," + adminModel.real_name; new BLL.selfMessage().AddMessage("开票申请审批通过1", model.inv_personNum, model.inv_personName, replaceContent, replaceUser); //钉钉通知申请人 Model.manager_oauth oauthModel = new BLL.manager_oauth().GetModel(model.inv_personNum); if (oauthModel != null && oauthModel.is_lock == 1 && !string.IsNullOrEmpty(oauthModel.oauth_userid)) { new BLL.selfMessage().sentDingMessage("发票申请审批通过", oauthModel.oauth_userid, replaceContent, replaceUser); } //通知业务员 DataSet ds = new BLL.Order().GetPersonList(0, "op_oid='" + model.inv_oid + "' and op_type=1", ""); if (ds != null && ds.Tables[0].Rows.Count > 0) { new BLL.selfMessage().AddMessage("开票申请审批通过1", ds.Tables[0].Rows[0]["op_number"].ToString(), ds.Tables[0].Rows[0]["op_name"].ToString(), replaceContent, replaceUser); } if (type == 1)//申请区域审批,审批通过要通知开票区域审批人 { if (model.inv_farea == model.inv_darea) { DataTable userDt = new BLL.manager().getUserByPermission("0402", new BLL.department().getGroupArea()).Tables[0]; if (userDt != null) { foreach (DataRow dr in userDt.Rows) { new BLL.selfMessage().AddMessage("开票申请审批通过2", dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser); //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage("开票申请审批通过2", dr["oauth_userid"].ToString(), replaceContent, replaceUser); } } } } else { DataTable userDt = new BLL.manager().getUserByPermission("0603", model.inv_darea).Tables[0]; if (userDt != null) { foreach (DataRow dr in userDt.Rows) { new BLL.selfMessage().AddMessage("开票申请审批通过2", dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser); //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage("开票申请审批通过2", dr["oauth_userid"].ToString(), replaceContent, replaceUser); } } } } } if (type == 2)//开票区域审批,审批通过要通知财务审批人 { DataTable userDt = new BLL.manager().getUserByPermission("0402", new BLL.department().getGroupArea()).Tables[0]; if (userDt != null) { foreach (DataRow dr in userDt.Rows) { new BLL.selfMessage().AddMessage("开票申请审批通过2", dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser); //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage("开票申请审批通过2", dr["oauth_userid"].ToString(), replaceContent, replaceUser); } } } } } return(""); } return("操作失败"); }
/// <summary> /// 增加一条数据 /// </summary> public string Add(Model.invoices model, Model.manager manager) { #region 验证数据 if (model.inv_cid == 0) { return("请选择客户"); } if (string.IsNullOrEmpty(model.inv_purchaserName)) { return("请填写购买方名称"); } if (string.IsNullOrEmpty(model.inv_purchaserNum)) { return("请填写购买方纳税人识别号"); } if (string.IsNullOrEmpty(model.inv_purchaserAddress)) { return("请填写购买方地址"); } if (string.IsNullOrEmpty(model.inv_purchaserPhone)) { return("请填写购买方电话"); } if (string.IsNullOrEmpty(model.inv_purchaserBank)) { return("请填写购买方开户行"); } if (string.IsNullOrEmpty(model.inv_purchaserBankNum)) { return("请填写购买方账号"); } if (string.IsNullOrEmpty(model.inv_serviceType)) { return("请选择应税劳务"); } if (string.IsNullOrEmpty(model.inv_serviceName)) { return("请选择服务名称"); } //if (model.inv_money <= 0) //{ // return "开票金额必须大于0"; //} if (string.IsNullOrEmpty(model.inv_sentWay)) { return("请选择送票方式"); } if (model.inv_sentWay == "邮寄") { if (string.IsNullOrEmpty(model.inv_receiveName)) { return("请填写收票人名称"); } if (string.IsNullOrEmpty(model.inv_receivePhone)) { return("请填写收票人电话"); } if (string.IsNullOrEmpty(model.inv_receiveAddress)) { return("请填写收票人地址"); } } if (string.IsNullOrEmpty(model.inv_darea)) { return("请选择开票区域"); } if (model.inv_unit == 0) { return("请选择开票单位"); } #endregion //验证权限:财务,订单的业务员、报账人员、执行人员,才能添加应收应付 Model.Order order = new BLL.Order().GetModel(model.inv_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.inv_farea = order.personlist.Where(p => p.op_type == 1).ToArray()[0].op_area; decimal?leftMoney = computeInvoiceLeftMoney(model.inv_oid, model.inv_cid.Value); model.inv_overMoney = leftMoney - model.inv_money >= 0 ? 0 : leftMoney - model.inv_money; int ret = dal.Add(model); if (ret > 0) { StringBuilder content = new StringBuilder(); content.Append("购买方名称:" + model.inv_purchaserName + "<br/>"); content.Append("购买方账号:" + model.inv_purchaserBankNum + "<br/>"); content.Append("金额:" + model.inv_money + "<br/>"); content.Append("应税劳务、服务名称:" + model.inv_serviceType + "," + model.inv_serviceName + "<br/>"); content.Append("送票方式:" + model.inv_sentWay + "<br/>"); content.Append("开票区域:" + model.inv_darea + "<br/>"); content.Append("开票单位:" + model.inv_unit + "<br/>"); Model.business_log logmodel = new Model.business_log(); logmodel.ol_relateID = ret; logmodel.ol_oid = model.inv_oid; logmodel.ol_cid = model.inv_cid.Value; logmodel.ol_title = "添加发票"; 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); //记录日志 //钉钉通知 DataTable userDt = new BLL.manager().getUserByPermission("0603", model.inv_farea).Tables[0]; if (userDt != null) { string replaceContent = new BLL.Customer().GetModel(model.inv_cid.Value).c_name + "," + model.inv_money; string replaceUser = manager.user_name + "," + manager.real_name; 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.invoices model, string content, Model.manager manager) { if (model == null) { return("数据不存在"); } Model.Order order = new BLL.Order().GetModel(model.inv_oid); if (order == null) { return("订单不存在"); } if (!new BLL.permission().checkHasPermission(manager, "0401"))//如果不是财务 { //验证权限:在同一个订单里,业务员与业务报账员可以对未审核地接进行编辑与删除!执行人员只能对自己地址进行编辑与删除操作! if (model.inv_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.inv_personNum != manager.user_name && !new BLL.permission().checkHasPermission(manager, "0403")) { return("无权限编辑"); } } if (model.inv_flag1 == 2 && model.inv_flag2 != 1 && model.inv_flag3 != 1) { return("已审批通过的不能编辑"); } #region 验证数据 if (string.IsNullOrEmpty(model.inv_purchaserName)) { return("请填写购买方名称"); } if (string.IsNullOrEmpty(model.inv_purchaserNum)) { return("请填写购买方纳税人识别号"); } if (string.IsNullOrEmpty(model.inv_purchaserAddress)) { return("请填写购买方地址"); } if (string.IsNullOrEmpty(model.inv_purchaserPhone)) { return("请填写购买方电话"); } if (string.IsNullOrEmpty(model.inv_purchaserBank)) { return("请填写购买方开户行"); } if (string.IsNullOrEmpty(model.inv_purchaserBankNum)) { return("请填写购买方账号"); } if (string.IsNullOrEmpty(model.inv_serviceType)) { return("请选择应税劳务"); } if (string.IsNullOrEmpty(model.inv_serviceName)) { return("请选择服务名称"); } //if (model.inv_money <= 0) //{ // return "开票金额必须大于0"; //} if (string.IsNullOrEmpty(model.inv_sentWay)) { return("请选择送票方式"); } if (model.inv_sentWay == "邮寄") { if (string.IsNullOrEmpty(model.inv_receiveName)) { return("请填写收票人名称"); } if (string.IsNullOrEmpty(model.inv_receivePhone)) { return("请填写收票人电话"); } if (string.IsNullOrEmpty(model.inv_receiveAddress)) { return("请填写收票人地址"); } } if (string.IsNullOrEmpty(model.inv_darea)) { return("请选择开票区域"); } if (model.inv_unit == 0) { return("请选择开票单位"); } #endregion if (model.inv_flag1 == 1 || model.inv_flag2 == 1 || model.inv_flag3 == 1) { model.inv_flag1 = 0; model.inv_checkName1 = ""; model.inv_checkNum1 = ""; model.inv_checkRemark1 = ""; model.inv_checkTime1 = null; model.inv_flag2 = 0; model.inv_checkName2 = ""; model.inv_checkNum2 = ""; model.inv_checkRemark2 = ""; model.inv_checkTime2 = null; model.inv_flag3 = 0; model.inv_checkName3 = ""; model.inv_checkNum3 = ""; model.inv_checkRemark3 = ""; model.inv_checkTime3 = null; } if (dal.Update(model)) { Model.business_log logmodel = new Model.business_log(); logmodel.ol_relateID = model.inv_id.Value; logmodel.ol_oid = model.inv_oid; logmodel.ol_cid = model.inv_cid.Value; logmodel.ol_title = "编辑发票"; 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); //记录日志 //钉钉通知 DataTable userDt = new BLL.manager().getUserByPermission("0603", model.inv_farea).Tables[0]; if (userDt != null) { string replaceContent = new BLL.Customer().GetModel(model.inv_cid.Value).c_name + "," + model.inv_money; string replaceUser = manager.user_name + "," + manager.real_name; 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("修改失败"); }