protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //if (Application["user"] != null) //{ if (!string.IsNullOrEmpty(Request.QueryString["IncomeId"])) //带参数访问为编辑状态 { Session["editFlag"] = "true"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayEditIncomediv();", true); CashIncomeInfo cashInfo = CashIncomeMethods.GetCashIncomeById(Convert.ToInt32(Request.QueryString["IncomeId"])); InitializeIncomeAdd(cashInfo); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplaySysdiv();", true); } queryList = new List <QueryElement>(); BindIncomeListDataGrid(queryList); //} //else //{ // Response.Redirect("~/Views/Login.aspx"); // Alert.Show(this, "请先登录!"); //} } }
public static int DeleteCashIncome(int id) { int iSuccess = 0; int uSuccess = 0; CashIncomeInfo cashInfo = CashInComeDAL.GetCashIncomeById(id); CardInfo cardInfo = CardDAL.GetCardById(cashInfo.CardId); CashInComeDAL.DeleteCashIncome(id, out iSuccess); if (iSuccess > 0) { float amount = cardInfo.Amount - cashInfo.IncomeAmount; float incomeAmount = cardInfo.IncomeAmount - cashInfo.IncomeAmount; CardDAL.UpdateCardAmount(amount, incomeAmount, cashInfo.CardId, 1, out uSuccess); } if (iSuccess > 0 && uSuccess > 0) { return(1); } else { return(0); } }
protected void btnIncomeAdd_Click(object sender, EventArgs e) { Session["editFlag"] = "false"; CashIncomeInfo info = new CashIncomeInfo(); InitializeIncomeAdd(info); this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayAddIncomediv();", true); }
/// <summary> ///编辑时初始化dropdownlist /// </summary> private void InitializeEditDropControl(CashIncomeInfo info) { this.dropIncomeAddInComeType.DataSource = StaticRescourse.GetIncomeType(); Helper.SetDropDownList(this.dropIncomeAddInComeType); this.dropIncomeAddPreRate.DataSource = StaticRescourse.GetRateType(); Helper.SetDropDownList(this.dropIncomeAddPreRate); this.dropIncomeAddRate.DataSource = StaticRescourse.GetRate(this.dropIncomeAddPreRate.SelectedItem.Text); Helper.SetDropDownList(this.dropIncomeAddRate); this.dropIncomeAddStatus.DataSource = StaticRescourse.GetIncomeStatus(); Helper.SetDropDownList(this.dropIncomeAddStatus); this.dropIncomeAddDepositMode.DataSource = StaticRescourse.GetIncomDepositMode(); Helper.SetDropDownList(this.dropIncomeAddDepositMode); this.dropIncomeAddPreMode.DataSource = StaticRescourse.GetRateType(); Helper.SetDropDownList(this.dropIncomeAddPreMode); this.dropIncomeAddMode.DataSource = StaticRescourse.GetMode(this.dropIncomeAddPreMode.SelectedItem.Text); Helper.SetDropDownList(this.dropIncomeAddMode); if (info.Id > 0) { this.dropIncomeAddInComeType.SelectedValue = info.IncomeType.ToString(); this.dropIncomeAddPreRate.SelectedValue = info.PreRate.ToString(); this.dropIncomeAddRate.SelectedValue = info.Rate.ToString(); this.dropIncomeAddStatus.SelectedValue = info.Status.ToString(); this.dropIncomeAddDepositMode.SelectedValue = info.DepositMode.ToString(); this.dropIncomeAddPreMode.SelectedValue = info.PreMode.ToString(); this.dropIncomeAddMode.SelectedValue = info.Mode.ToString(); } else { this.dropIncomeAddInComeType.SelectedValue = "1"; this.dropIncomeAddPreRate.SelectedValue = "1"; this.dropIncomeAddRate.SelectedValue = "1"; this.dropIncomeAddStatus.SelectedValue = "1"; this.dropIncomeAddDepositMode.SelectedValue = "1"; this.dropIncomeAddPreMode.SelectedValue = "1"; this.dropIncomeAddMode.SelectedValue = "1"; } }
public static CashIncomeInfo GetCashIncomeById(int id) { CashIncomeInfo cashIncomeInfo = new CashIncomeInfo(); StringBuilder sb = new StringBuilder(); sb.Append(" select * from cashincome where Id=@Id"); MySqlParameter par = new MySqlParameter("@Id", MySqlDbType.Int32); par.Value = id; using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString(), par)) { while (reader.Read()) { cashIncomeInfo = new CashIncomeInfo(reader); } } return(cashIncomeInfo); }
private void BindIncomeListDataGrid(List <QueryElement> list) { CashIncomeCollection coll = CashIncomeMethods.GetCashIncome(list); this.IncomeListDataGrid.DataSource = coll; this.IncomeListDataGrid.DataBind(); for (int i = 0; i < coll.Count; i++) { CashIncomeInfo cashInfo = coll[i]; CardInfo cardInfo = CardMethods.GetCardByCardNumber(cashInfo.CardNumber, cashInfo.OwnerId); string bank = StaticRescourse.DisplayBank(cardInfo.BankId); this.IncomeListDataGrid.Items[i].Cells[1].Text = StaticRescourse.DisplayIncomeStatus(cashInfo.Status); this.IncomeListDataGrid.Items[i].Cells[4].Text = StaticRescourse.DisplayIncomeType(cashInfo.IncomeType); this.IncomeListDataGrid.Items[i].Cells[6].Text = StaticRescourse.DisplayMode(cashInfo.Mode); this.IncomeListDataGrid.Items[i].Cells[7].Text = StaticRescourse.DisplayRate(cashInfo.Rate); this.IncomeListDataGrid.Items[i].Cells[8].Text = cashInfo.DepositDate.ToString("yyyy-MM-dd"); if (cashInfo.AutoSave == 1) { this.IncomeListDataGrid.Items[i].Cells[12].Text = "是"; } else { this.IncomeListDataGrid.Items[i].Cells[12].Text = "否"; } if (HelperCommon.CompareAccordToRequired(cashInfo.BDate)) { this.IncomeListDataGrid.Items[i].Cells[9].Text = cashInfo.BDate.ToString("yyyy-MM-dd"); } else { this.IncomeListDataGrid.Items[i].Cells[9].Text = string.Empty; } if (HelperCommon.CompareAccordToRequired(cashInfo.EDate)) { this.IncomeListDataGrid.Items[i].Cells[10].Text = cashInfo.EDate.ToString("yyyy-MM-dd"); } else { this.IncomeListDataGrid.Items[i].Cells[10].Text = string.Empty; } this.IncomeListDataGrid.Items[i].Cells[13].Text = StaticRescourse.DisplayIncomeDepositMode(cashInfo.DepositMode); } }
public static int InsertOrUpdatetocashincome(CashIncomeInfo info) { int iSuccess = 0; int uSuccess = 0; CashIncomeInfo cashIncomeInfo = new CashIncomeInfo(); if (info.Id > 0) { cashIncomeInfo = CashInComeDAL.GetCashIncomeById(info.Id); } CashInComeDAL.InsertOrUpdatetocashincome(info, out iSuccess); if (iSuccess > 0 || iSuccess == -1) { CardInfo cardInfo = CardDAL.GetCardById(info.CardId); float amount = 0; float incomeamount = 0; if (info.Id > 0) { amount = cardInfo.Amount + (info.IncomeAmount - cashIncomeInfo.IncomeAmount); incomeamount = cardInfo.IncomeAmount + (info.IncomeAmount - cashIncomeInfo.IncomeAmount); } else { amount = cardInfo.Amount + info.IncomeAmount; incomeamount = cardInfo.IncomeAmount + info.IncomeAmount; } CardDAL.UpdateCardAmount(amount, incomeamount, info.CardId, 1, out uSuccess); } if (iSuccess > 0 && uSuccess > 0) { return(1); } else if (iSuccess == -1 && uSuccess > 0) { return(-1); } else { return(0); } }
/// <summary> ///新增初始化 /// </summary> /// <param name="info"></param> private void InitializeIncomeAdd(CashIncomeInfo info) { if (info.Id > 0) { #region 编辑时初始化 this.dropIncomeAddCardNumber.Enabled = false; List <DropItem> card = new List <DropItem>(); card.Add(new DropItem { DisplayField = info.CardNumber, ValueField = info.CardId.ToString() }); this.dropIncomeAddCardNumber.DataSource = card; Helper.SetDropDownList(this.dropIncomeAddCardNumber); this.dropIncomeAddCardNumber.SelectedValue = info.CardId.ToString(); #endregion } else { this.dropIncomeAddCardNumber.Enabled = true; InitializeDropIncomeCardNumber(); } DateTime date = new DateTime(2000, 1, 1); this.txtIncomeAddAmount.Text = info.IncomeAmount > 0 ? info.IncomeAmount.ToString() : string.Empty; this.txtIncomeAddDepositDate.Text = info.DepositDate > date?info.DepositDate.ToString("yyyy-MM-dd") : DateTime.Now.ToString("yyyy-MM-dd"); this.txtIncomeAddDepositorName.Text = !string.IsNullOrEmpty(info.DepositorName) ? info.DepositorName : string.Empty; this.txtIncomeAddBDate.Text = info.BDate > date?info.BDate.ToString("yyyy-MM-dd") : string.Empty; this.txtIncomeAddContent.Text = !string.IsNullOrEmpty(info.Content) ? info.Content : string.Empty; this.txtIncomeAddOwner.Text = !string.IsNullOrEmpty(info.OwnerName) ? info.OwnerName : string.Empty; if (info.AutoSave == 1) { this.checkIncomeAddAutoSave.Checked = true; } else { this.checkIncomeAddAutoSave.Checked = false; } InitializeEditDropControl(info); }
public static void InsertOrUpdatetocashincome(CashIncomeInfo info, out int iSuccess) { StringBuilder sb = new StringBuilder(); CashIncomeInfo cashIncomeInfo = GetCashIncomeById(info.Id); if (cashIncomeInfo.Id > 0) { sb.Append(" update cashincome set OwnerId=@OwnerId,OwnerName=@OwnerName,IncomeAmount = @IncomeAmount,PreMode = @PreMode,Mode = @Mode,PreRate=@PreRate,Rate=@Rate, "); sb.Append(" DepositDate = @DepositDate,BDate = @BDate,EDate=@EDate,AutoSave=@AutoSave,DepositorId=@DepositorId,DepositorName=@DepositorName,DepositMode=@DepositMode,"); sb.Append(" Status=@Status,IncomeType=@IncomeType,TAmount=@TAmount,Content=@Content where Id=@Id"); } else { sb.Append(" insert into cashincome (OwnerId,OwnerName,CardId,CardNumber,BankCardNumber,IncomeAmount,PreMode,Mode,PreRate,Rate,DepositDate,BDate,EDate,AutoSave,DepositorId, "); sb.Append(" DepositorName,DepositMode,Status,IncomeType,TAmount,Content) "); sb.Append(" Values(@OwnerId,@OwnerName,@CardId,@CardNumber,@BankCardNumber, @IncomeAmount,@PreMode,@Mode,@PreRate,@Rate,@DepositDate,@BDate,@EDate,@AutoSave,@DepositorId,"); sb.Append(" @DepositorName,@DepositMode,@Status,@IncomeType,@TAmount,@Content)"); } MySqlParameter[] pars = new MySqlParameter[] { new MySqlParameter("@Id", MySqlDbType.Int32), new MySqlParameter("@OwnerId", MySqlDbType.Int32), new MySqlParameter("@OwnerName", MySqlDbType.String), new MySqlParameter("@CardId", MySqlDbType.Int32), new MySqlParameter("@CardNumber", MySqlDbType.String), new MySqlParameter("@BankCardNumber", MySqlDbType.String), new MySqlParameter("@IncomeAmount", MySqlDbType.Float), new MySqlParameter("@PreMode", MySqlDbType.Int32), new MySqlParameter("@Mode", MySqlDbType.Int32), new MySqlParameter("@PreRate", MySqlDbType.Int32), new MySqlParameter("@Rate", MySqlDbType.Int32), new MySqlParameter("@DepositDate", MySqlDbType.DateTime), new MySqlParameter("@BDate", MySqlDbType.DateTime), new MySqlParameter("@EDate", MySqlDbType.DateTime), new MySqlParameter("@AutoSave", MySqlDbType.Int32), new MySqlParameter("@DepositorId", MySqlDbType.Int32), new MySqlParameter("@DepositorName", MySqlDbType.String), new MySqlParameter("@DepositMode", MySqlDbType.Int32), new MySqlParameter("@Status", MySqlDbType.Int32), new MySqlParameter("@IncomeType", MySqlDbType.Int32), new MySqlParameter("@TAmount", MySqlDbType.Float), new MySqlParameter("@Content", MySqlDbType.String) }; pars[0].Value = info.Id; pars[1].Value = info.OwnerId; pars[2].Value = info.OwnerName; pars[3].Value = info.CardId; pars[4].Value = info.CardNumber; pars[5].Value = info.BankCardNumber; pars[6].Value = info.IncomeAmount; pars[7].Value = info.PreMode; pars[8].Value = info.Mode; pars[9].Value = info.PreRate; pars[10].Value = info.Rate; pars[11].Value = info.DepositDate; pars[12].Value = info.BDate; pars[13].Value = info.EDate; pars[14].Value = info.AutoSave; pars[15].Value = info.DepositorId; pars[16].Value = info.DepositorName; pars[17].Value = info.DepositMode; pars[18].Value = info.Status; pars[19].Value = info.IncomeType; pars[20].Value = info.TAmount; pars[21].Value = info.Content; iSuccess = MySqlDBHelper.ExecuteCommand(sb.ToString(), pars); if (cashIncomeInfo.Id > 0) { iSuccess = -1; } }
protected void btnIncomeEditSave_Click(object sender, EventArgs e) { CashIncomeInfo info = new CashIncomeInfo(); #region 验证 if (Session["editFlag"].Equals("true")) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayEditIncomediv();", true); info.Id = Convert.ToInt32(Request.QueryString["IncomeId"]); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayAddIncomediv();", true); } if (string.IsNullOrEmpty(this.dropIncomeAddCardNumber.SelectedValue)) { Alert.Show(this, "请选择卡号!"); this.dropIncomeAddCardNumber.Focus(); return; } if (string.IsNullOrEmpty(this.dropIncomeAddInComeType.SelectedValue)) { Alert.Show(this, "请输入收入类型!"); this.dropIncomeAddInComeType.Focus(); return; } if (string.IsNullOrEmpty(this.dropIncomeAddMode.SelectedValue)) { Alert.Show(this, "请输入存款状态!"); this.dropIncomeAddMode.Focus(); return; } if (string.IsNullOrEmpty(this.txtIncomeAddAmount.Text.Trim())) { Alert.Show(this, "请输入收入金额!"); this.txtIncomeAddAmount.Focus(); return; } if (string.IsNullOrEmpty(this.dropIncomeAddRate.SelectedValue)) { Alert.Show(this, "请输入利率!"); this.dropIncomeAddRate.Focus(); return; } if (string.IsNullOrEmpty(this.txtIncomeAddDepositDate.Text.Trim())) { Alert.Show(this, "请输入存款日期!"); this.txtIncomeAddDepositDate.Focus(); return; } if (string.IsNullOrEmpty(this.txtIncomeAddDepositorName.Text.Trim())) { Alert.Show(this, "请输入存款人!"); this.txtIncomeAddDepositDate.Focus(); return; } if (!string.IsNullOrEmpty(this.txtIncomeAddBDate.Text.Trim()) || !string.IsNullOrEmpty(this.txtIncomeAddEDate.Text.Trim())) { if (!string.IsNullOrEmpty(this.txtIncomeAddBDate.Text.Trim()) && string.IsNullOrEmpty(this.txtIncomeAddEDate.Text.Trim())) { Alert.Show(this, "请输入到期日期!"); this.txtIncomeAddEDate.Focus(); return; } else if (string.IsNullOrEmpty(this.txtIncomeAddBDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtIncomeAddEDate.Text.Trim())) { Alert.Show(this, "请输入定存开始日期!"); this.txtIncomeAddBDate.Focus(); return; } else { bool comparflag = true; comparflag = HelperCommon.ValidDateTime(string.Format("{0:d}", this.txtIncomeAddBDate.Text.Trim()), string.Format("{0:d}", this.txtIncomeAddEDate.Text.Trim())); if (!comparflag) { Alert.Show(this, "到期日期不能小于开始日期"); this.txtIncomeAddEDate.Focus(); return; } comparflag = HelperCommon.ComparDay(string.Format("{0:d}", this.txtIncomeAddBDate.Text.Trim()), string.Format("{0:d}", this.txtIncomeAddEDate.Text.Trim())); if (!comparflag) { Alert.Show(this, "定存日期必须大于等于三个月!"); this.txtIncomeAddEDate.Focus(); return; } } } if (string.IsNullOrEmpty(this.dropIncomeAddStatus.SelectedValue)) { Alert.Show(this, "请选择收入状态!"); this.dropIncomeAddStatus.Focus(); return; } if (string.IsNullOrEmpty(this.dropIncomeAddDepositMode.SelectedValue)) { Alert.Show(this, "请选存款方式!"); this.dropIncomeAddDepositMode.Focus(); return; } if (string.IsNullOrEmpty(this.txtIncomeAddOwner.Text.Trim())) { Alert.Show(this, "请输入资产所有者!"); this.txtIncomeAddOwner.Focus(); return; } #endregion #region 赋值 UserInfo userInfo = UserMethods.GetUserByName(this.txtIncomeAddOwner.Text.Trim()); info.OwnerName = this.txtIncomeAddOwner.Text.Trim(); userInfo = UserMethods.GetUserByName(this.txtIncomeAddOwner.Text.Trim()); if (userInfo.Id > 0) { info.OwnerId = userInfo.Id; } else { info.OwnerId = 0; } CardInfo cardInfo = CardMethods.GetCardById(Convert.ToInt32(this.dropIncomeAddCardNumber.SelectedValue)); info.CardNumber = cardInfo.CardNumber; info.BankCardNumber = cardInfo.CardNumber + " " + StaticRescourse.DisplayBank(cardInfo.BankId); info.CardId = Convert.ToInt32(this.dropIncomeAddCardNumber.SelectedItem.Value); info.IncomeAmount = Convert.ToSingle(this.txtIncomeAddAmount.Text.Trim()); info.PreMode = Convert.ToInt32(this.dropIncomeAddPreMode.SelectedValue); info.Mode = Convert.ToInt32(this.dropIncomeAddMode.SelectedValue); info.PreRate = Convert.ToInt32(this.dropIncomeAddPreRate.SelectedValue); info.Rate = Convert.ToInt32(this.dropIncomeAddRate.SelectedValue); info.DepositDate = HelperCommon.ConverToDateTime(string.Format("{0:d}", this.txtIncomeAddDepositDate.Text.Trim())); if (!string.IsNullOrEmpty(this.txtIncomeAddBDate.Text.Trim())) { info.BDate = HelperCommon.ConverToDateTime(string.Format("{0:d}", this.txtIncomeAddBDate.Text.Trim())); } if (!string.IsNullOrEmpty(this.txtIncomeAddEDate.Text.Trim())) { info.EDate = HelperCommon.ConverToDateTime(string.Format("{0:d}", this.txtIncomeAddEDate.Text.Trim())); } if (this.checkIncomeAddAutoSave.Checked) { info.AutoSave = 1; } else { info.AutoSave = 0; } userInfo = UserMethods.GetUserByName(this.txtIncomeAddDepositorName.Text.Trim()); if (userInfo.Id > 0) { info.DepositorId = userInfo.Id; } else { info.DepositorId = 0; } info.DepositorName = this.txtIncomeAddDepositorName.Text.Trim(); info.DepositMode = Convert.ToInt32(this.dropIncomeAddDepositMode.SelectedValue); info.Status = Convert.ToInt32(this.dropIncomeAddStatus.SelectedValue); info.IncomeType = Convert.ToInt32(this.dropIncomeAddInComeType.SelectedValue); info.TAmount = info.IncomeAmount; info.Content = !string.IsNullOrEmpty(this.txtIncomeAddContent.Text.Trim()) ? this.txtIncomeAddContent.Text.Trim() : string.Empty; #endregion int iSuccess = CashIncomeMethods.InsertOrUpdatetocashincome(info); this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayAddIncomediv();", true); if (iSuccess > 0) { Alert.Show(this, "新增一条收入成功!"); } else if (iSuccess == -1) { Alert.Show(this, "修改成功!"); } else { Alert.Show(this, "操作失败!"); } InitializeIncomeAdd(new CashIncomeInfo()); queryList = new List <QueryElement>(); BindIncomeListDataGrid(queryList); }
public static int InsertOrUpdatetocashincome(CashIncomeInfo info) { return(CashIncomeProxy.InsertOrUpdatetocashincome(info)); }