123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- 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;
- using System.IO;
- using LYFZ.ComponentLibrary;
- namespace LYFZ.Software.MainBusiness.Dresses
- {
- public partial class FrmDressEntry : LYFZ.Software.UI.Dresses.FrmDressEntry
- {
- private delegate void UpdateControl();
- public FrmDressEntry()
- {
- this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
- this.dgv.MouseDoubleClick += dgv_MouseDoubleClick;
- }
- #region 加载
- protected override void FrmDressEntry_Shown(object sender, EventArgs e)
- {
- try
- {
- cmbDsfm_IsEnabled.SelectedIndex = 1;
- BindDsfm_DressType();
- Bind();
- #region 权限设置
- #region 增加礼服
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressEntry, CustomAttributes.OperatingAuthority.Add))
- {
- btnAdd.Enabled = true;
- }
- else
- {
- btnAdd.Enabled = false;
- }
- #endregion
- #region 修改礼服
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressEntry, CustomAttributes.OperatingAuthority.Update))
- {
- btnUpdate.Enabled = true;
- }
- else
- {
- btnUpdate.Enabled = false;
- }
- #endregion
- #region 删除礼服
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressEntry, CustomAttributes.OperatingAuthority.Delete))
- {
- btnDelete.Enabled = true;
- }
- else
- {
- btnDelete.Enabled = false;
- }
- #endregion
- #region 导出礼服
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OrdersCustomerCompetence, CustomAttributes.OperatingAuthority.DataExport))
- {
- btnExport.Enabled = true;
- }
- else
- {
- btnExport.Enabled = false;
- }
- #endregion
- #endregion
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- public void Bind()
- {
- this.ucPagerEx1.PageCurrent = 1;
- this.ucPagerEx1.PageSize = 100;
- this.ucPagerEx1.Bind();
- }
- #endregion
- #region 增加
- protected override void btnAdd_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.Software.MainBusiness.Dresses.DressEntry.FrmEntry set = new DressEntry.FrmEntry();
- set.Type = "Add";
- if (set.ShowDialog() == DialogResult.OK)
- {
- Bind();
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 修改
- protected override void btnUpdate_Click(object sender, EventArgs e)
- {
- try
- {
- if (dgv.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("请选择你要修改的礼服!");
- return;
- }
- LYFZ.Software.MainBusiness.Dresses.DressEntry.FrmEntry set = new DressEntry.FrmEntry();
- set.Dsfm_DressNumber = dgv.CurrentRow.Cells["Dsfm_DressNumber"].Value.ToString();
- set.Type = "Update";
- if (set.ShowDialog() == DialogResult.OK)
- {
- Bind();
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- void dgv_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- try
- {
- if (e.Location.Y > this.dgv.ColumnHeadersHeight)
- {
- if (dgv.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("请选择你要修改的礼服!");
- return;
- }
- #region 权限设置
- #region 修改礼服
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressEntry, CustomAttributes.OperatingAuthority.Update))
- {
- btnUpdate.Enabled = true;
- }
- else
- {
- btnUpdate.Enabled = false;
- return;
- }
- #endregion
- #endregion
- LYFZ.Software.MainBusiness.Dresses.DressEntry.FrmEntry set = new DressEntry.FrmEntry();
- set.Dsfm_DressNumber = dgv.CurrentRow.Cells["Dsfm_DressNumber"].Value.ToString();
- set.Type = "Update";
- if (set.ShowDialog() == DialogResult.OK)
- {
- Bind();
- }
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- protected override void dgv_DoubleClick(object sender, EventArgs e)
- {
- }
- #endregion
- #region 删除
- protected override void btnDelete_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgv.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("请选中你要删除的数据!");
- return;
- }
- DataTable dt = new DataTable();
- #region 判断是否存在礼服租售洗
- string Dsfm_DressNumber = dgv.CurrentRow.Cells["Dsfm_DressNumber"].Value.ToString();
- LYFZ.BLL.BLL_ErpDressSaleRentalDetail DressSaleRentalDetailBll = new BLL.BLL_ErpDressSaleRentalDetail();
- LYFZ.BLL.BLL_ErpSystemConfigure SystemConfigureBll = new BLL.BLL_ErpSystemConfigure();
- DataTable dtmax = DressSaleRentalDetailBll.View_DressSaleRentalDetailDay(" and Dsrd_DressNumber='" + Dsfm_DressNumber + "'").Tables[0];
- DataTable dts = SystemConfigureBll.GetList("Sconfig_Code='AlsoClothesDay'").Tables[0];
- if (dtmax.Rows.Count > 0)
- {
- if (!string.IsNullOrEmpty(dtmax.Rows[0]["maxtime"].ToString().Trim()))
- {
- DateTime Day = Convert.ToDateTime(dtmax.Rows[0]["maxtime"].ToString()).AddDays(Convert.ToDouble(dts.Rows[0]["Sconfig_Value"].ToString()));
- if (DateTime.Now <= Day)
- {
- MessageBoxCustom.Show("此礼服不能删除,已经使用中!");
- return;
- }
- }
- }
- #endregion
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- LYFZ.BLL.BLL_ErpDressFrom bll = new BLL.BLL_ErpDressFrom();
- int id = Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value);
- dt = new DataTable();
- dt = bll.View_tb_ErpDressFrom(" and Id=" + id + "").Tables[0];
- string Dsfm_PicturePath = dt.Rows[0]["Dsfm_PicturePath"].ToString();
- if (!string.IsNullOrEmpty(Dsfm_PicturePath))
- {
- //删除原图图片
- File.Delete((BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + dt.Rows[0]["Dsfm_PicturePath"]));
- //删除缩略图
- char[] paths = Path.GetExtension(Dsfm_PicturePath).ToCharArray();
- Dsfm_PicturePath = Dsfm_PicturePath.TrimEnd(paths);
- File.Delete(BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + Dsfm_PicturePath + "&Small" + Path.GetExtension(dt.Rows[0]["Dsfm_PicturePath"].ToString()));
- }
- if (bll.Delete(id) == true)
- {
- MessageBoxCustom.Show("删除成功!");
- #region 写入操作日志
- string logsContent = "删除礼服名称:" + dgv.CurrentRow.Cells["Dsfm_DressName"].Value.ToString();
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除礼服, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- //LYFZ.BLL.BLL_ErpSystemLogs systemLogsBll = new BLL.BLL_ErpSystemLogs();
- //LYFZ.Model.Model_ErpSystemLogs systemLogsModel = new Model.Model_ErpSystemLogs();
- //systemLogsModel.Slogs_Type = "user";
- //systemLogsModel.Slogs_Topic = "删除礼服";
- //systemLogsModel.Slogs_Content = "删除礼服名称:" + dgv.CurrentRow.Cells["Dsfm_DressName"].Value.ToString();
- //systemLogsModel.Slogs_UserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
- //systemLogsModel.Slogs_IP = "";
- //systemLogsModel.Slogs_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- //systemLogsModel.Slogs_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- //systemLogsBll.Add(systemLogsModel);
- #endregion
- Bind();
- }
- else { MessageBoxCustom.Show("删除失败!"); }
- }
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- #endregion
- #region 导出
- protected override void btnExport_Click(object sender, EventArgs e)
- {
- try
- {
- dgv.ExportDataTable();
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 查询
- protected override void btnSlect_Click(object sender, EventArgs e)
- {
- try
- {
- Bind();
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 绑定礼服类别
- /// <summary>
- /// 绑定礼服类别
- /// </summary>
- public void BindDsfm_DressType()
- {
- CtvDsfm_DressType.TreeView.Nodes.Clear();
- #region 绑定二级礼服类别
- LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
- DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID='59'").Tables[0];
- if (tbl.Rows.Count > 0)
- {
- TreeNode root = null;
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- if (i == 0)
- {
- root = new TreeNode("全部");
- this.CtvDsfm_DressType.TreeView.Nodes.Add(root);
- }
- root = new TreeNode();
- root.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
- root.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
- this.CreateTreeViewShop(root.Nodes, tbl.Rows[i]["ID"].ToString());
- this.CtvDsfm_DressType.TreeView.Nodes.Add(root);
- }
- }
- #endregion
- }
- private void CreateTreeViewShop(TreeNodeCollection nodes, string ClassCode)
- {
- if (ClassCode != "")
- {
- LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
- DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID=" + ClassCode + "").Tables[0];
- if (tbl.Rows.Count > 0)
- {
- TreeNode node;
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- node = new TreeNode();
- node.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
- node.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
- nodes.Add(node);
- }
- }
- }
- }
- #endregion
- #region 画分页
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
- {
- dgv.Rows.Clear();
- LYFZ.BLL.BLL_ErpDressFrom DressFrombll = new BLL.BLL_ErpDressFrom();
- DataTable dt = new DataTable();
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- StringBuilder StrWhere = new StringBuilder();
- StrWhere.Append("1=1 ");
- if (!string.IsNullOrEmpty(CtvDsfm_DressType.Text) && CtvDsfm_DressType.Text != "全部")
- {
- StrWhere.Append(" and Dsfm_DressType='" + CtvDsfm_DressType.Tag.ToString() + "' ");
- }
- if (!string.IsNullOrEmpty(txtkeyword.Text))
- {
- StrWhere.Append(" and (Dsfm_DressNumber like '%" + txtkeyword.Text + "%' or Dsfm_DressName like '%" + txtkeyword.Text + "%')");
- }
- if (!string.IsNullOrEmpty(cmbDsfm_IsEnabled.Text))
- {
- if (cmbDsfm_IsEnabled.Text == "上架")
- {
- StrWhere.Append(" and Dsfm_IsEnabled=1");
- }
- else { StrWhere.Append(" and Dsfm_IsEnabled=0"); }
- }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- pageData.TableName = "View_tb_ErpDressFrom";
- pageData.PageIndex = this.ucPagerEx1.PageCurrent;
- pageData.PageSize = this.ucPagerEx1.PageSize;
- pageData.QueryCondition = StrWhere.ToString();
- pageData.QueryFieldName = "ID,Dsfm_DressNumber,Dsfm_DressType,Dsfm_DressName,Dsfm_DressBrand,Dsfm_DressSize,Dsfm_DressQuantity,Dsfm_CostPrice,Dsfm_RentPrice,Dsfm_SalePrice,Dsfm_IsEnabled,Dsfm_PlacedRegion,Dsfm_PicturePath,Dsfm_DressIntroduce,Dsfm_DressDetail,Dsfm_DressRemark,Dsfm_CreateDateTime,Dsfm_CreateName,Dsfm_UpdateDateTime,Dsfm_UpdateName,Dsfm_DressTypeName,Dsfm_PlacedRegionName ";
- pageData.OrderStr = "ID desc";
- pageData.OrderType = 1;
- DataSet da = pageData.QueryDataTable();
- dt = da.Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new UpdateControl(delegate()
- {
- #region 获取礼服表
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- #region
- 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]["Dsfm_DressNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_DressTypeName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_PlacedRegionName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_DressName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_DressBrand"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_DressSize"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_DressQuantity"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_CostPrice"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_RentPrice"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_SalePrice"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_IsEnabled"].ToString().Trim() == "0" ? "下架" : "上架";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDateTime(dt.Rows[t]["Dsfm_CreateDateTime"].ToString().Trim()).ToString("yyyy-MM-dd");
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsfm_DressRemark"].ToString().Trim();
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- dgv.ClearSelection();
- #endregion
- }
- #endregion
- }));
- }
- });
- try
- {
- this.ucPagerEx1.TbDataSource = dt;
- }
- catch { }
- return pageData.TotalCount;
- }
- #endregion
- }
- }
|