/// <summary> /// 审核补扣款 /// </summary> /// <param name="d"></param> /// <param name="tran"></param> /// <returns></returns> public static int UpdateDeduct(DeductModel d, SqlTransaction tran) { string sql = "update deduct set isAudit=1,AuditTime=@auditingtime,OperateIP=@OperateIP,OperateNum=@OperateNum,AuditExpectNum=@AuditExpectNum where id=@id"; SqlParameter[] par = new SqlParameter[] { new SqlParameter("@auditingtime", d.AuditingTime), new SqlParameter("@OperateIP", d.OperateIP), new SqlParameter("@OperateNum", d.OperateNum), new SqlParameter("@AuditExpectNum", d.Auditingexctnum), new SqlParameter("@id", d.ID) }; return(DBHelper.ExecuteNonQuery(tran, sql, par, CommandType.Text)); }
protected void gvdeduct_RowCommand(object sender, GridViewCommandEventArgs e) { string id = e.CommandArgument.ToString(); string sql = "select * from deduct where id=" + id; DataTable dt = DAL.DBHelper.ExecuteDataTable(sql); DeductModel model = new DeductModel(); if (dt.Rows.Count > 0) { model.Auditing = 1; model.DeductMoney = Convert.ToDouble(dt.Rows[0]["DeductMoney"]); model.ExpectNum = CommonDataBLL.getMaxqishu(); model.ID = Convert.ToInt32(id); model.IsDeduct = Convert.ToInt32(dt.Rows[0]["IsDeduct"]); model.Number = dt.Rows[0]["Number"].ToString(); model.OperateIP = Request.UserHostAddress; model.OperateNum = Session["Company"].ToString(); model.AuditingTime = DateTime.Now.ToUniversalTime(); model.Auditingexctnum = CommonDataBLL.getMaxqishu(); model.Actype = Convert.ToInt32(dt.Rows[0]["Actype"]);; } if (e.CommandName == "ok") { if (dt.Rows[0]["isaudit"].ToString() == "1") { ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("000849", "不能重复审核") + "')</script>"); return; } if (DeductBLL.UpdateInfoTranBD(model)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("000858", "审核成功") + "')</script>"); BtnConfirm_Click(null, null); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("006041", "审核失败") + "!')</script>"); } } if (e.CommandName == "del") { if (DAL.DBHelper.ExecuteNonQuery("delete from deduct where id=" + id, CommandType.Text) > 0) { ScriptHelper.SetAlert(Page, GetTran("000008", "删除成功")); BtnConfirm_Click(null, null); } else { ScriptHelper.SetAlert(Page, GetTran("000009", "删除失败")); } } }
/// <summary> /// 审核补扣款 /// </summary> /// <param name="info">扣补款对象</param> public static bool UpdateInfoTran(DeductModel info) { using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { if (DeductDAL.UpdateDeduct(info, tran) <= 0) { tran.Rollback(); return(false); } if (!ReleaseDAL.UpdateDeductOut(tran, info.Number, info.IsDeduct, info.DeductMoney)) { tran.Rollback(); return(false); } DirectionEnum de = DirectionEnum.AccountsIncreased; if (info.IsDeduct == 0) { de = DirectionEnum.AccountReduced; } string remark = ""; if (info.IsDeduct == 0) { remark = "008021~【" + info.Number + "】~000153~" + info.ExpectNum + "~008022"; D_AccountDAL.AddAccountWithdraw1(info.Number, info.DeductMoney, D_AccountSftype.MemberType, D_Sftype.BounsAccount, D_AccountKmtype.AddMoneycut, de, remark, tran); } else { remark = "008021~【" + info.Number + "】~000153~" + info.ExpectNum + "~008023"; D_AccountDAL.AddAccountWithdraw1(info.Number, info.DeductMoney, D_AccountSftype.MemberType, D_Sftype.BounsAccount, D_AccountKmtype.AddMoneyget, de, remark, tran); } tran.Commit(); return(true); } catch { tran.Rollback(); return(false); } finally { conn.Close(); conn.Dispose(); } } }
/// <summary> /// 审核补扣款 /// </summary> /// <param name="info">扣补款对象</param> public static bool UpdateInfoTranBD(DeductModel info) { using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { if (DeductDAL.UpdateDeduct(info, tran) <= 0) { tran.Rollback(); return(false); } if (!ReleaseDAL.UpdateDeductOutBD(tran, info.Number, info.IsDeduct, info.Actype, info.DeductMoney)) { tran.Rollback(); return(false); } DirectionEnum de = DirectionEnum.AccountReduced; D_AccountKmtype km = D_AccountKmtype.AddMoneycut; string remark = "管理员协助扣款" + info.DeductMoney.ToString(); if (info.IsDeduct == 1) { de = DirectionEnum.AccountsIncreased; km = D_AccountKmtype.AddMoneyget; remark = "管理员协助补款" + info.DeductMoney.ToString(); } D_AccountDAL.AddAccountWithdraw1(info.Number, info.DeductMoney, D_AccountSftype.MemberType, D_Sftype.BounsAccount, km, de, remark, tran); tran.Commit(); return(true); } catch { tran.Rollback(); return(false); } finally { conn.Close(); conn.Dispose(); } } }
/// <summary> /// 根据期数和编号查询扣补款信息 /// </summary> /// <param name="expectnum">期数</param> /// <param name="number">编号</param> /// <returns></returns> public static DeductModel GetDeductInfo(int expectnum, string number) { DeductModel info = null; string sql = "select ID,DeductMoney,DeductReason,ExpectNum,Number from Deduct where Deduct.ExpectNum=@ExpectNum and Deduct.Number=@Number"; SqlParameter[] parm = new SqlParameter[] { new SqlParameter("@ExpectNum", SqlDbType.Int), new SqlParameter("@Number", SqlDbType.VarChar, 50) }; parm[0].Value = expectnum; parm[1].Value = number; SqlDataReader reader = DBHelper.ExecuteReader(sql, parm, CommandType.Text); if (reader.Read()) { info = new DeductModel(reader.GetInt32(0)); info.DeductMoney = 0;// double.Parse(reader["DeductMoney"].ToString()); info.DeductReason = reader["DeductReason"].ToString(); info.ExpectNum = Convert.ToInt32(reader["ExpectNum"].ToString()); info.Number = reader["Number"].ToString(); } reader.Close(); return(info); }
/// <summary> /// 添加扣款或补款信息 /// </summary> /// <param name="info">扣补款对象</param> public static bool AddInfo(SqlTransaction tran, DeductModel info) { SqlParameter[] parm = new SqlParameter[] { new SqlParameter("@Number", SqlDbType.NVarChar, 50), new SqlParameter("@DeductMoney", SqlDbType.Money), new SqlParameter("@DeductReason", SqlDbType.Text), new SqlParameter("@ExpectNum", SqlDbType.Int), new SqlParameter("@IsDeduct", SqlDbType.Bit), new SqlParameter("@OperateIP", SqlDbType.VarChar, 50), new SqlParameter("@OperateNum", SqlDbType.VarChar, 50), new SqlParameter("@KeyinDate", SqlDbType.DateTime) }; parm[0].Value = info.Number; parm[1].Value = info.DeductMoney; parm[2].Value = info.DeductReason; parm[3].Value = info.ExpectNum; parm[4].Value = info.IsDeduct; parm[5].Value = info.OperateIP; parm[6].Value = info.OperateNum; parm[7].Value = DateTime.Now.ToUniversalTime(); return(DBHelper.ExecuteNonQuery(tran, "Deduct_Withhold", parm, CommandType.StoredProcedure) > 0?true:false); }
/// <summary> /// 添加扣款或补款信息 /// </summary> /// <param name="info">扣补款对象</param> public static bool AddInfo(DeductModel info) { SqlParameter[] parm = new SqlParameter[] { new SqlParameter("@Number", SqlDbType.NVarChar, 50), new SqlParameter("@DeductMoney", SqlDbType.Money), new SqlParameter("@DeductReason", SqlDbType.Text), new SqlParameter("@ExpectNum", SqlDbType.Int), new SqlParameter("@IsDeduct", SqlDbType.Int), new SqlParameter("@OperateIP", SqlDbType.VarChar, 50), new SqlParameter("@OperateNum", SqlDbType.VarChar, 50), new SqlParameter("@KeyinDate", SqlDbType.DateTime), new SqlParameter("@actype", info.Actype) }; parm[0].Value = info.Number; parm[1].Value = info.DeductMoney; parm[2].Value = info.DeductReason; parm[3].Value = info.ExpectNum; parm[4].Value = info.IsDeduct; parm[5].Value = info.OperateIP; parm[6].Value = info.OperateNum; parm[7].Value = DateTime.Now.ToUniversalTime(); return(DBHelper.ExecuteNonQuery("insert into Deduct (Number,DeductMoney,DeductReason,ExpectNum,IsDeduct,OperateIP,OperateNum,KeyinDate,actype) values (@Number,@DeductMoney,@DeductReason,@ExpectNum,@IsDeduct,@OperateIP,@OperateNum,@KeyinDate,@actype)", parm, CommandType.Text) > 0 ? true : false); }
private bool GetAudit(DeductModel info) { bool bl = false; using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { if (DeductDAL.UpdateDeduct(info, tran) <= 0) { tran.Rollback(); return(false); } string p = "pointEin =pointEin +" + info.DeductMoney; if (info.IsDeduct == 0) { p = "pointEout =pointEout +" + info.DeductMoney; } int r = DBHelper.ExecuteNonQuery(tran, "update memberinfo set " + p + " where number='" + info.Number + "'"); if (r == 0) { tran.Rollback(); return(false); } //对账单 string rem = "扣款"; D_AccountKmtype dakm = D_AccountKmtype.AddMoneycut; DirectionEnum dem = DirectionEnum.AccountReduced; if (info.IsDeduct == 0) { dakm = D_AccountKmtype.AddMoneycut; } else if (info.IsDeduct == 1) { dakm = D_AccountKmtype.AddMoneyget; dem = DirectionEnum.AccountsIncreased; rem = "补款"; } int c = D_AccountDAL.AddAccount("E", info.Number, info.DeductMoney, D_AccountSftype.MemberType, dakm, dem, "管理员添加" + rem + " " + info.DeductMoney, tran); if (c == 0) { tran.Rollback(); return(false); } tran.Commit(); return(true); } catch { tran.Rollback(); return(false); } finally { conn.Close(); conn.Dispose(); } } return(bl); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { string cname = e.CommandName.ToString(); if (cname == "Lbtn") { if (DeductBLL.isExistsBonusDifference(Convert.ToInt32(e.CommandArgument))) { this.Page.RegisterStartupScript("", "<script>alert('" + GetTran("005965", "已经添加,不能再添加!") + "');</script>"); return; } else { DeductBLL.upBonusDifference(Convert.ToInt32(e.CommandArgument)); BonusDifferenceModel model = DeductBLL.GetBonusDifference(Convert.ToInt32(e.CommandArgument)); MemberInfoModel memberinfo = DeductBLL.GetMemberInfo(model.Number); DeductModel deduct = new DeductModel(); deduct.Number = model.Number; deduct.DeductMoney = model.Chayi; if (model.Chayi >= 0) { deduct.DeductReason = GetTran("000024", "会员编号") + ":" + model.Number + "," + GetTran("000107", "姓名") + ":" + Encryption.Encryption.GetDecipherName(memberinfo.Name) + "," + GetTran("000252", "补款") + ":" + model.Chayi + ",第" + model.Qishu + GetTran("006033", "期结算后的差异"); deduct.IsDeduct = 1; } else { deduct.DeductReason = GetTran("000024", "会员编号") + ":" + model.Number + "," + GetTran("000107", "姓名") + ":" + Encryption.Encryption.GetDecipherName(memberinfo.Name) + "," + GetTran("000251", "扣款") + ":" + model.Chayi + "," + GetTran("000156", "第") + model.Qishu + GetTran("006033", "期结算后的差异"); deduct.IsDeduct = 0; } deduct.ExpectNum = BLL.CommonClass.CommonDataBLL.getMaxqishu(); deduct.OperateIP = CommonDataBLL.OperateIP; deduct.OperateNum = CommonDataBLL.OperateBh; DeductBLL.AddInfo(deduct); this.Page.RegisterStartupScript("", "<script>alert('" + GetTran("001401", "操作成功!") + "');</script>"); bind(); } } if (cname == "Del") { if (DeductBLL.isExistsBonusDifference(Convert.ToInt32(e.CommandArgument))) { this.Page.RegisterStartupScript("", "<script>alert('" + GetTran("005966", "已经添加,不能删除!") + "');</script>"); return; } else { if (DeductBLL.isDelBonusDifference(Convert.ToInt32(e.CommandArgument))) { DeductBLL.DelBonusDifference(Convert.ToInt32(e.CommandArgument)); this.Page.RegisterStartupScript("", "<script>alert('" + GetTran("000749", "删除成功!") + "');</script>"); } else { this.Page.RegisterStartupScript("", "<script>alert('" + GetTran("005997", "已经被删除,不能再删!") + "');</script>"); } bind(); } } }
/// <summary> /// 提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { this.question.Text = question.Text.Trim(); this.money.Text = money.Text.Trim(); //设置特定值防止重复提交 hid_fangzhi.Value = "0"; if (this.rad_Deduct.SelectedValue == "") { ScriptHelper.SetAlert(Page, GetTran("007748", "请选择补扣款项")); return; } string number = ""; string sql = "select number from MemberInfo where MobileTele='" + txtbh.Text + "'"; DataTable shj = DBHelper.ExecuteDataTable(sql); if (shj.Rows.Count > 0) { number = shj.Rows[0][0].ToString(); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002096", "无此编号,请检查后再重新输入") + "!')</script>"); return; } if (number != "" && this.question.Text != "" && this.money.Text != "") { string vquestion; //判断会员是否存在 if (DeductBLL.IsExist(number)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002096", "无此编号,请检查后再重新输入") + "!')</script>"); return; } double d; if (!double.TryParse(money.Text, out d)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002095", "金额输入有误") + "!')</script>"); return; } if (d <= 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("001539", "操作失败,输入的金额不能小于0") + "!')</script>"); return; } else { int iskou = int.Parse(rad_Deduct.SelectedValue); //0为扣,1为补 vquestion = this.question.Text.Trim(); DeductModel model = new DeductModel(); model.Number = DisposeString.DisString(number.Trim(), "<,>,',-", "<,>,', ", ","); model.DeductMoney = d; model.DeductReason = vquestion; model.ExpectNum = CommonDataBLL.getMaxqishu(); model.IsDeduct = iskou; model.Actype = 1; model.OperateIP = CommonDataBLL.OperateIP; model.OperateNum = CommonDataBLL.OperateBh; try { if (DeductBLL.AddDeduct(model)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("000006", "添加成功") + "!');window.location.href='DeductSalary.aspx';</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("000007", "添加失败") + "!')</script>"); } } catch (Exception) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("001507", "操作失败") + "!')</script>"); } } } else { ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("002094", "所有项必填,请重新输入") + "!')</script>"); } clear(); }
/// <summary> /// 添加扣款或补款信息 /// </summary> /// <param name="info">扣补款对象</param> public static void AddInfo(DeductModel info) { DeductDAL.AddInfo(info); }
public static bool AddDeduct(DeductModel info) { return(DeductDAL.AddInfo(info)); }