123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.Dresses.DressManagement.Rental
- {
- public partial class FrmAlsoBack : LYFZ.Software.UI.Dresses.DressManagement.Rental.FrmAlsoBack
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpDressSendWashOrder sworbll = new BLL.BLL_ErpDressSendWashOrder();
- LYFZ.BLL.BLL_ErpDressSendWashDetail swodbll = new BLL.BLL_ErpDressSendWashDetail();
- LYFZ.BLL.BLL_ErpDressSaleRentalDetail rsdbll = new BLL.BLL_ErpDressSaleRentalDetail();
- public FrmAlsoBack()
- {
- this.dgv.CellMouseDown += dgv_CellMouseDown;
- this.dgv.DataGridViewConMenu_ItemClicked += dgv_DataGridViewConMenu_ItemClicked;
- }
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 订单号
- /// </summary>
- public string StrOrderNumber;
- /// <summary>
- /// 订单类型
- /// </summary>
- public string OrderType;
- /// <summary>
- /// 登录者姓名
- /// </summary>
- string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void FrmAlsoBack_Shown(object sender, EventArgs e)
- {
- this.dgv.Rows.Clear();
- if (!string.IsNullOrEmpty(this.StrOrderNumber))
- {
- if (this.OrderType == "送洗")
- {
- #region 获取礼服资料
- DataTable dt = orbll.GetView_Custom("tb_ErpDressSendWashDetail Left Join tb_ErpDressFrom on Dsfm_DressNumber = Dswd_DressNumber", StrWhere: "Dswd_Number='" + this.StrOrderNumber + "'", ShowColumnName: "tb_ErpDressSendWashDetail.ID,Dswd_DressNumber,Dsfm_DressCustomNumber,Dswd_DressName,Dswd_BackStatus,Dswd_BackName,Dswd_BackTime").Tables[0];
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- if (!string.IsNullOrEmpty(dt.Rows[t]["Dsfm_DressCustomNumber"].ToString().Trim()))
- { cell.Value = dt.Rows[t]["Dsfm_DressCustomNumber"].ToString().Trim(); }
- else
- { cell.Value = dt.Rows[t]["Dswd_DressNumber"].ToString().Trim(); }
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dswd_DressName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "1";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- if (dt.Rows[t]["Dswd_BackStatus"].ToString().Trim() == "1")
- { cell.Value = "已还"; }
- else if (dt.Rows[t]["Dswd_BackStatus"].ToString().Trim() == "2")
- { cell.Value = "报损"; }
- else if (dt.Rows[t]["Dswd_BackStatus"].ToString().Trim() == "3")
- { cell.Value = "未还"; }
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- DataRow dtRow = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dt.Rows[t]["Dswd_BackName"].ToString().Trim());
- if (dtRow != null)
- { cell.Value = dtRow["User_Name"].ToString().Trim(); }
- else
- { cell.Value = ""; }
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[t]["Dswd_BackTime"]);
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- this.dgv.ClearSelection();
- #endregion
- }
- else
- {
- #region 获取礼服资料
- DataTable dt = orbll.GetView_Custom("tb_ErpDressSaleRentalDetail Left Join tb_ErpDressFrom on Dsfm_DressNumber = Dsrd_DressNumber", StrWhere: "Dsrd_Number='" + this.StrOrderNumber + "'", ShowColumnName: "tb_ErpDressSaleRentalDetail.ID,Dsrd_DressNumber,Dsfm_DressCustomNumber,Dsrd_DressName,Dsrd_BackStatus,Dsrd_BackName,Dsrd_BackTime").Tables[0];
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsrd_DressNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsrd_DressName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "1";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- if (dt.Rows[t]["Dsrd_BackStatus"].ToString().Trim() == "1")
- { cell.Value = "已还"; }
- else if (dt.Rows[t]["Dsrd_BackStatus"].ToString().Trim() == "2")
- { cell.Value = "报损"; }
- else if (dt.Rows[t]["Dsrd_BackStatus"].ToString().Trim() == "3")
- { cell.Value = "未还"; }
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- DataRow dtRow = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dt.Rows[t]["Dsrd_BackName"].ToString().Trim());
- if (dtRow != null)
- { cell.Value = dtRow["User_Name"].ToString().Trim(); }
- else
- { cell.Value = ""; }
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[t]["Dsrd_BackTime"]);
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- this.dgv.ClearSelection();
- #endregion
- }
- }
- }
- /// <summary>
- /// dgv控件里面塞下拉框
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void cmbFactory_Leave(object sender, EventArgs e)
- {
- this.dgv.CurrentRow.Cells["Dsrd_BackStatus"].Value = this.cmbFactory.Text.Trim();
- if (this.dgv.CurrentRow.Cells["Dsrd_BackStatus"].Value.ToString().Trim() == "未还")
- {
- this.dgv.CurrentRow.Cells["Dsro_UpdateName"].Value = "";
- this.dgv.CurrentRow.Cells["Dsrd_BackTime"].Value = "";
- }
- else
- {
- this.dgv.CurrentRow.Cells["Dsro_UpdateName"].Value = this.StrUserName;
- this.dgv.CurrentRow.Cells["Dsrd_BackTime"].Value = LYFZ.Command.Command_Validate.DateTimeToString(SDateTime.Now);
- }
- this.dgv.CurrentRow.Tag = "1";
- this.cmbFactory.Visible = false;
- }
- /// <summary>
- /// 双击列表事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgv_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (this.dgv.Rows.Count > 0)
- {
- if (e.RowIndex >= 0)
- {
- if (this.dgv.CurrentCell.ColumnIndex == this.dgv.Columns["Dsrd_BackStatus"].Index)
- {
- DataGridViewCell cell = this.dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];
- Rectangle rect = this.dgv.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, true);
- this.cmbFactory.Location = new Point(rect.Location.X + this.dgv.Location.X, rect.Location.Y + this.dgv.Location.Y);
- this.cmbFactory.Size = rect.Size;
- if (cell.Value != null)
- { this.cmbFactory.Text = (string)cell.Value; }
- this.cmbFactory.Visible = true;
- this.cmbFactory.Focus();
- }
- }
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSave_Click(object sender, EventArgs e)
- {
- if (this.dgv.Rows.Count > 0)
- {
- DateTime StrTime = SDateTime.Now;
- string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- int YHCount = 0;
- for (int i = 0; i < this.dgv.Rows.Count; i++)
- {
- if (this.dgv.Rows[i].Tag != null)
- {
- string StrBackStatus = "";
- switch (this.dgv.Rows[i].Cells["Dsrd_BackStatus"].Value.ToString().Trim())
- {
- case "已还": StrBackStatus = "1"; YHCount++; break;
- case "报损": StrBackStatus = "2"; break;
- case "未还": StrBackStatus = "3"; break;
- }
- if (this.OrderType == "送洗")
- {
- LYFZ.Model.Model_ErpDressSendWashDetail model = swodbll.GetModel(Convert.ToInt32(this.dgv.Rows[i].Cells["ID"].Value));
- model.Dswd_BackStatus = StrBackStatus;
- if (StrBackStatus == "3")
- {
- model.Dswd_BackTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
- model.Dswd_BackName = "";
- }
- else
- {
- model.Dswd_BackTime = StrTime;
- model.Dswd_BackName = StrUserID;
- }
- model.Dswd_UpdateDatetime = StrTime;
- model.Dswd_UpdateName = StrUserID;
- clist.Add(swodbll.GetUpdateCommandInfo(model));
- }
- else
- {
- LYFZ.Model.Model_ErpDressSaleRentalDetail model = rsdbll.GetModel(Convert.ToInt32(this.dgv.Rows[i].Cells["ID"].Value));
- model.Dsrd_BackStatus = StrBackStatus;
- if (StrBackStatus == "3")
- {
- model.Dsrd_BackTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
- model.Dsrd_BackName = "";
- }
- else
- {
- model.Dsrd_BackTime = StrTime;
- model.Dsrd_BackName = StrUserID;
- }
- model.Dsrd_UpdateDateTime = StrTime;
- model.Dsrd_UpdateName = StrUserID;
- clist.Add(rsdbll.GetUpdateCommandInfo(model));
- }
- }
- }
- if (clist.Count > 0)
- {
- if (MessageBoxCustom.Show("你确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- this.IsSaveed = true;
- System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
- {
- if (this.OrderType != "送洗" && this.dgv.Rows.Count==YHCount)
- {
- Model.SMSParameters sparameters = new Model.SMSParameters();
- sparameters.OrderNumber = this.StrOrderNumber;
- new LYFZ.BLL.BLL_SMSTemplates().GenerateEventSMS(EnumPublic.SmsSendEvent.礼服出租还衣后X分钟, sparameters, MainBusiness.CommonLogical.SuccessfulLogin.CurrentCompanyInfoID);
- }
- }));
- t.Start();
- MessageBoxCustom.Show("保存成功!");
- }
- else
- { MessageBoxCustom.Show("保存失败!"); }
- }
- else
- { MessageBoxCustom.Show("没做任何修改,不需要保存!"); }
- }
- }
- /// <summary>
- /// 右键菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgv_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
- {
- this.cmbFactory.Visible = false;
- if (e.Button == MouseButtons.Right)
- {
- ToolStripMenuItem item = null;
- if (e.ColumnIndex == this.dgv.Columns["Dsrd_BackStatus"].Index)
- {
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresTotakePiece, LYFZ.CustomAttributes.OperatingAuthority.OrderSendOut))
- {
- item = new ToolStripMenuItem();
- item.Text = "已还";
- item.Tag = "S";
- this.dgv.conMenu.Items.Add(item);
- item = new ToolStripMenuItem();
- item.Text = "未还";
- item.Tag = "S";
- this.dgv.conMenu.Items.Add(item);
- }
- }
- }
- }
- /// <summary>
- /// 右键菜单选择项事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgv_DataGridViewConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- ToolStripItem item = e.ClickedItem;
- if (item.Tag.ToString().Trim() == "S" && !string.IsNullOrEmpty(item.Text.Trim()))
- {
- for (int i = 0; i < this.dgv.SelectedRows.Count; i++)
- {
- this.dgv.SelectedRows[i].Cells["Dsrd_BackStatus"].Value = item.Text.Trim();
- if (item.Text.Trim() == "未还")
- {
- this.dgv.CurrentRow.Cells["Dsro_UpdateName"].Value = "";
- this.dgv.CurrentRow.Cells["Dsrd_BackTime"].Value = "";
- }
- else
- {
- this.dgv.CurrentRow.Cells["Dsro_UpdateName"].Value = this.StrUserName;
- this.dgv.CurrentRow.Cells["Dsrd_BackTime"].Value = LYFZ.Command.Command_Validate.DateTimeToString(SDateTime.Now);
- }
- this.dgv.SelectedRows[i].Tag = "1";
- }
- }
- }
- }
- }
|