123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932 |
- using LYFZ.ComponentLibrary;
- using LYFZ.Software.MainBusiness.DoorCityProcess;
- 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.Web.UI.WebControls;
- namespace LYFZ.Software.MainBusiness.InitialSet
- {
- public partial class FrmProductSet : LYFZ.Software.UI.InitialSet.FrmProductSet
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpProduct ptbll = new BLL.BLL_ErpProduct();
- LYFZ.BLL.BLL_ErpPlusPickItems ppisbll = new BLL.BLL_ErpPlusPickItems();
- LYFZ.BLL.BLL_ErpWeddingService orwsbll = new BLL.BLL_ErpWeddingService();
- LYFZ.BLL.BLL_ErpOrderProductList orptbll = new BLL.BLL_ErpOrderProductList();
- public FrmProductSet()
- {
- this.Load += FrmProductSet_Load;
- this.Shown += FrmProductSet_Shown;
- this.btnSet.Click += btnSet_Click;
- this.btnSupplierSelect.Click += btnSupplierSelect_Click;
- this.listViewData_Product.Click += listViewData_Product_Click;
- this.btnReset.Click += btnReset_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.btnClose.Click += btnClose_Click;
- this.btnSave.Click += btnSave_Click;
- this.btnUnit.Click += btnUnit_Click;
- this.btnPicDelete.Click += btnPicDelete_Click;
- this.btnUpload.Click += btnUpload_Click;
- this.btnQuery.Click += btnQuery_Click;
- this.txtQueryText.KeyDown += txtQueryText_KeyDown;
- this.cmbtreevProdClassQuery.ComboBoxTree_NodeMouseClick += cmbtreevProdClassQuery_ComboBoxTree_NodeMouseClick;
- this.txtProd_PurchasePrice.KeyPress += txtProd_PurchasePrice_KeyPress;
- this.txtProd_SalesPrice.KeyPress += txtProd_SalesPrice_KeyPress;
- this.txtProd_CostPrice.KeyPress += txtProd_CostPrice_KeyPress;
- this.txtProd_Batch.KeyPress += txtProd_Batch_KeyPress;
- this.txtProd_AlarmQuantity.KeyPress += txtProd_AlarmQuantity_KeyPress;
- this.txtProd_PrintArea.KeyPress += txtProd_PrintArea_KeyPress;
- this.txtProd_Name.TextChanged += txtProd_Name_TextChanged;
- this.txtProd_Name.KeyPress += txtProd_Name_KeyPress;
- this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
- this.chkUpperShelves.Click += chkUpperShelves_Click;
- this.chkDownShelves.Click += chkDownShelves_Click;
- this.picFam_PhotoAlbum.Click += picFam_PhotoAlbum_Click;
- this.txtProd_Width.Text = "0";
- this.txtProd_Height.Text = "0";
- this.btn_UpdateLoad.Click += btn_UpdateLoad_Click;
- }
- void btn_UpdateLoad_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(this.txtProd_Name.Text))
- {
- LYFZ.Software.MainBusiness.Dresses.frmSubmitDataToService submitService = new Dresses.frmSubmitDataToService();
- submitService.InitDataInfo(this.txtProd_Name.Tag.ToString(), "Product");
- submitService.ShowDialog();
- }
- }
- /// <summary>
- /// 相片集合
- /// </summary>
- ImageList mlistImage = new ImageList();
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmProductSet_Load(object sender, EventArgs e)
- {
- this.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
- this.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
- this.listViewData_Product.View = View.Details;
- this.listViewData_Product.GridLines = true;
- string[] StrColumns = "商品名称,单位,进价,卖价,制作费,状态,商品状况".Split(',');
- int ColumnOneWidth = (this.listViewData_Product.Width - 23) / 3;
- for (int i = 0; i < StrColumns.Length; i++)
- {
- ColumnHeader ch = new ColumnHeader();
- ch.Text = StrColumns[i].Trim();
- ch.TextAlign = HorizontalAlignment.Left;
- if (i == 0)
- { ch.Width = ColumnOneWidth; }
- else
- { ch.Width = (this.listViewData_Product.Width - 23 - ColumnOneWidth) / 5; }
- switch (StrColumns[i].Trim())
- {
- case "进价":
- case "卖价":
- case "制作费":
- ch.TextAlign = HorizontalAlignment.Right;
- break;
- default:
- ch.TextAlign = HorizontalAlignment.Center;
- break;
- }
- this.listViewData_Product.Columns.Add(ch);
- }
- this.mlistImage.ImageSize = new Size(30, 30);
- this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
- this.listViewData_Product.SmallImageList = mlistImage;
- this.CreateListViewGroup();
- }
- /// <summary>
- /// 获取商品设置数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmProductSet_Shown(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAA", this.cmbtreevProdClass);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAA", this.cmbtreevProdClassQuery, IsFirstNodeNull: true, IsFirstNodeName: "全部");
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAG", this.cmbtreevProdUnit, IsFirstNodeNull: true);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevProdIsEnabled, "上架,下架", IsFirstNodeNull: true);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevProdAvailability, "减库存,不减库存", IsFirstNodeNull: true);
- chkUpperShelves.Checked = true;
- //获取商品名称与商品编号
- this.PublicFunctionRows();
- // 保存新商品
- if (this.listViewData_Product.Items.Count == 0)
- {
- this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ProductCompetence, CustomAttributes.OperatingAuthority.Add);
- this.btnSet.Enabled = btnSave.Enabled;
- this.btnUnit.Enabled = btnSave.Enabled;
- }
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ProductCompetence, CustomAttributes.OperatingAuthority.Delete);
-
- }
- /// <summary>
- /// 创建默认分组
- /// </summary>
- void CreateListViewGroup()
- {
- DataTable dtGroup = orbll.GetView_Custom("tb_ErpProduct Left Join tb_ErpSystemCategory on Prod_Class = Sc_ClassCode", StrWhere: "", ShowColumnName: "Sc_ClassName,Prod_Class", GroupBy: "Sc_ClassName,Prod_Class").Tables[0];
- if (dtGroup.Rows.Count > 0)
- {
- for (int i = 0; i < dtGroup.Rows.Count; i++)
- {
- if (this.listViewData_Product.Groups[dtGroup.Rows[i]["Prod_Class"].ToString().Trim()] == null)
- {
- ListViewGroup man_lvg = new ListViewGroup();
- man_lvg.Name = dtGroup.Rows[i]["Prod_Class"].ToString().Trim();
- man_lvg.Header = dtGroup.Rows[i]["Sc_ClassName"].ToString().Trim();
- man_lvg.HeaderAlignment = HorizontalAlignment.Left;
- this.listViewData_Product.Groups.Add(man_lvg);
- }
- }
- if (!this.listViewData_Product.ShowGroups)
- { this.listViewData_Product.ShowGroups = true; }
- }
- }
- /// <summary>
- /// 设置商品类别
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSet_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new FrmSystemSet();
- frm.TypeName = "AAAAAAA";
- frm.Version = "Version";
- if (frm.ShowDialog() == DialogResult.OK)
- {
- this.cmbtreevProdClass.SetTextAndTag_ValueNull();
- this.cmbtreevProdClassQuery.SetTextAndTag_ValueNull();
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAA", this.cmbtreevProdClass);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAA", this.cmbtreevProdClassQuery, IsFirstNodeNull: true, IsFirstNodeName: "全部");
- this.CreateListViewGroup();
- }
- }
- /// <summary>
- /// 选择供应商
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSupplierSelect_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.SetSmallForm.SelectVendorSetSmallForm frm = new SetSmallForm.SelectVendorSetSmallForm();
- frm.StrProvideValue = this.txtProd_Vendor.Text.Trim();
- frm.ShowDialog();
- if (frm.IsSaveed)
- { this.txtProd_Vendor.Text = frm.StrSelectedValue.Trim(); }
- }
- /// <summary>
- /// 列表点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void listViewData_Product_Click(object sender, EventArgs e)
- {
- if (this.listViewData_Product.Items.Count > 0 && this.listViewData_Product.SelectedItems.Count > 0)
- {
- string StrProdcutNumber = this.listViewData_Product.SelectedItems[0].Tag.ToString().Trim();
- #region 判断商品是否存在其它表中
- //订单商品表
- DataTable dt_OrderProductList = orptbll.GetList("OPlist_ProdNumber='" + StrProdcutNumber + "'").Tables[0];
- //婚庆服务
- DataTable dt_WeddingService = orwsbll.GetList("Ws_ProdNumber='" + StrProdcutNumber + "'").Tables[0];
- //二销商品
- DataTable dt_PlusPickItems = ppisbll.GetList("Plu_Goods like '%" + StrProdcutNumber + "%'").Tables[0];
- if (dt_OrderProductList.Rows.Count > 0 || dt_WeddingService.Rows.Count > 0 || dt_PlusPickItems.Rows.Count > 0)
- {
- this.txtProd_Name.ReadOnly = true;
- this.btnDelete.Enabled = false;
- }
- else
- {
- this.txtProd_Name.ReadOnly = false;
- this.btnDelete.Enabled = true;
- }
- #endregion
- DataTable dt = ptbll.GetList("Prod_Number='" + StrProdcutNumber + "'").Tables[0];
- this.cmbtreevProdClass.TagFindText(dt.Rows[0]["Prod_Class"].ToString().Trim());
- this.txtProd_Name.Text = dt.Rows[0]["Prod_Name"].ToString().Trim();
- this.txtProd_Name.Tag = dt.Rows[0]["Prod_Number"].ToString().Trim();
- this.cmbtreevProdUnit.TextFindTag(dt.Rows[0]["Prod_Unit"].ToString().Trim());
- this.txtProd_CostPrice.Text = dt.Rows[0]["Prod_CostPrice"].ToString().Trim();
- this.txtProd_SalesPrice.Text = dt.Rows[0]["Prod_SalesPrice"].ToString().Trim();
- this.txtProd_PurchasePrice.Text = dt.Rows[0]["Prod_PurchasePrice"].ToString().Trim();
- this.txtProd_Remark.Text = dt.Rows[0]["Prod_Remark"].ToString().Trim();
- this.txtProd_CostPrice.Text = dt.Rows[0]["Prod_CostPrice"].ToString().Trim();
- this.cmbtreevProdIsEnabled.TextFindTag(Convert.ToBoolean(dt.Rows[0]["Prod_IsEnabled"].ToString().Trim()) == true ? "上架" : "下架");
- this.txtProd_AlarmQuantity.Text = dt.Rows[0]["Prod_AlarmQuantity"].ToString().Trim();
- this.txtProd_Batch.Text = dt.Rows[0]["Prod_Batch"].ToString().Trim();
- this.cmbtreevProdAvailability.TextFindTag(dt.Rows[0]["Prod_Availability"].ToString().Trim() == "0" ? "不减库存" : "减库存");
- this.txtProd_PrintArea.Text = dt.Rows[0]["Prod_PrintArea"].ToString().Trim();
- this.txtProd_Vendor.Text = dt.Rows[0]["Prod_Vendor"].ToString().Trim();
- int width = 0, height = 0;
- if (int.TryParse(dt.Rows[0]["Prod_Width"].ToString(), out width))
- this.txtProd_Width.Text = (width / 10000.0).ToString();
- else
- this.txtProd_Width.Text = "0";
- if (int.TryParse(dt.Rows[0]["Prod_Height"].ToString(), out height))
- this.txtProd_Height.Text = (height / 10000.0).ToString();
- else
- this.txtProd_Height.Text = "0";
- if (!string.IsNullOrEmpty(dt.Rows[0]["Prod_Thumbnail"].ToString().Trim()))
- {
- this.picFam_PhotoAlbum.BeginInvoke((Action)delegate()
- { this.picFam_PhotoAlbum.Image = PublicCodeClasses.GetImage(PublicCodeClasses.StringToByte(dt.Rows[0]["Prod_Thumbnail"].ToString().Trim())); });
- }
- else
- { this.picFam_PhotoAlbum.Image = null; }
- int pStatus = Convert.ToInt32(dt.Rows[0]["Prod_ProductStatus"]);
- if(pStatus==1)
- {
- this.rdo_Product.Checked = true;
- }
- else
- {
- this.rdo_HalfProduct.Checked = true;
- }
- }
- this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ProductCompetence, CustomAttributes.OperatingAuthority.Update);
- }
- /// <summary>
- /// 重置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnReset_Click(object sender, EventArgs e)
- {
- this.txtProd_Name.Text = "";
- this.txtProd_Name.Tag = null;
- this.cmbtreevProdUnit.SetTextAndTag_ValueNull();
- this.txtProd_CostPrice.Text = "";
- this.txtProd_SalesPrice.Text = "";
- this.txtProd_PurchasePrice.Text = "";
- this.cmbtreevProdIsEnabled.SetTextAndTag_ValueNull();
- this.txtProd_Remark.Text = "";
- this.txtProd_AlarmQuantity.Text = "";
- this.txtProd_Batch.Text = "0";
- this.txtProd_Name.ReadOnly = false;
- this.cmbtreevProdAvailability.SetTextAndTag_ValueNull();
- this.txtProd_PrintArea.Text = "0";
- this.txtProd_Vendor.Text = "";
- this.picFam_PhotoAlbum.Image = null;
- this.txtProd_Width.Text = "0";
- this.txtProd_Height.Text = "0";
- this.rdo_Product.Checked = true;
- }
- /// <summary>
- /// 删除商品设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDelete_Click(object sender, EventArgs e)
- {
- if (this.txtProd_Name.Tag == null)
- { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
- DataTable dt = ptbll.GetList("Prod_Number='" + this.txtProd_Name.Tag.ToString().Trim() + "'", "ID desc").Tables[0];
- if (dt.Rows.Count > 0)
- {
- int id = Convert.ToInt32(dt.Rows[0]["ID"]);
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- if (ptbll.Delete(id) == true)
- {
- #region 写入操作日志
- string logsContent = "删除商品名称:" + txtProd_Name.Text.Trim();
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除商品, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- #endregion
- MessageBoxCustom.Show("删除成功!");
- this.btnReset_Click(this, null);
- this.listViewData_Product.Items.Remove(this.listViewData_Product.SelectedItems[0]);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Product);
- }
- else
- { MessageBoxCustom.Show("删除失败!"); }
- }
- }
- else
- { MessageBoxCustom.Show("找不到商品'" + this.txtProd_Name.Text.Trim() + "',或已被删除!"); }
- }
- /// <summary>
- /// 关闭页面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSave_Click(object sender, EventArgs e)
- {
- #region 判断资料不能为空
- if (string.IsNullOrEmpty(this.cmbtreevProdClass.Text.Trim()))
- { MessageBoxCustom.Show("商品类别名称不能为空!"); return; }
- if (string.IsNullOrEmpty(this.txtProd_Name.Text.Trim()))
- { MessageBoxCustom.Show("商品名称不能为空!"); return; }
- if (string.IsNullOrEmpty(this.txtProd_Batch.Text.Trim()))
- { MessageBoxCustom.Show("请输入商品的P数"); return; }
- if (string.IsNullOrEmpty(this.txtProd_CostPrice.Text.Trim()))
- { MessageBoxCustom.Show("商品成本不能为空!"); return; }
- if (string.IsNullOrEmpty(this.txtProd_SalesPrice.Text.Trim()))
- { MessageBoxCustom.Show("商品卖价不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbtreevProdIsEnabled.Text.Trim()))
- { MessageBoxCustom.Show("状态不能为空!"); return; }
- if (string.IsNullOrEmpty(txtProd_AlarmQuantity.Text.Trim()))
- { MessageBoxCustom.Show("报警数量不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbtreevProdAvailability.Text.Trim()))
- { MessageBoxCustom.Show("库存状态不能为空!"); return; }
- if (this.txtProd_Name.Text.Trim().Length > 50)
- { MessageBoxCustom.Show("商品名称长度不能超过50字!"); return; }
- #endregion
- LYFZ.Model.Model_ErpProduct model = null;
- #region 增加
- try
- {
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- if (this.txtProd_Name.Tag == null)
- {
- if (ptbll.Exists("Prod_Name", this.txtProd_Name.Text))
- { MessageBoxCustom.Show("商品名称已经存在!"); return; }
- model = new Model.Model_ErpProduct();
- model.Prod_Number = LYFZ.BLL.BLL_ErpProduct.GetNewProdNumber();
- model.Prod_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID();
- model.Prod_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtProd_Name.Text.Trim());
- model.Prod_Class = this.cmbtreevProdClass.Tag.ToString();
- model.Prod_Unit = this.cmbtreevProdUnit.Text.Trim();
- model.Prod_CostPrice = Convert.ToDecimal(this.txtProd_CostPrice.Text);
- model.Prod_SalesPrice = Convert.ToDecimal(this.txtProd_SalesPrice.Text);
- model.Prod_SpecialPrice = 0;
- if (string.IsNullOrEmpty(this.txtProd_PurchasePrice.Text))
- { model.Prod_PurchasePrice = 0; }
- else
- { model.Prod_PurchasePrice = Convert.ToDecimal(this.txtProd_PurchasePrice.Text); }
- model.Prod_IsRetail = false;
- if (this.cmbtreevProdIsEnabled.Text.Trim() == "下架")
- { model.Prod_IsEnabled = false; }
- else
- { model.Prod_IsEnabled = true; }
- model.Prod_Introduction = "";
- model.Prod_Detail = "";
- model.Prod_Remark = this.txtProd_Remark.Text;
- model.Prod_Quantity = 0;
- model.Prod_Thumbnail = "";
- model.Prod_FullSizeImage = "";
- model.Prod_Expedited = false;
- model.Prod_CreateDateTime = SDateTime.Now;
- model.Prod_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
- model.Prod_Batch = Convert.ToInt32(this.txtProd_Batch.Text);
- model.Prod_ClassName = this.cmbtreevProdClass.Text;
- model.Prod_AlarmQuantity = Convert.ToInt32(this.txtProd_AlarmQuantity.Text);
- model.Prod_Thumbnail = PublicCodeClasses.ToHexString(PublicCodeClasses.ImageDatabytes(this.picFam_PhotoAlbum));
- model.Prod_PrintArea = this.txtProd_PrintArea.Text.Trim();
- model.Prod_Vendor = this.txtProd_Vendor.Text.Trim();
- model.Prod_Width = (int)(Convert.ToSingle(this.txtProd_Width.Text) * 10000);
- model.Prod_Height = (int)(Convert.ToSingle(this.txtProd_Height.Text) * 10000);
- if (this.cmbtreevProdAvailability.Text.Trim() == "不减库存")
- { model.Prod_Availability = 0; }
- else
- { model.Prod_Availability = 1; }
- model.Prod_ProductStatus = rdo_Product.Checked ? 1 : 0;
- clist.Add(ptbll.GetAddCommandInfo(model));
- }
- else
- {
- #region 判断商品名称是否存在
- if (!string.IsNullOrEmpty(this.txtProd_Name.Text.Trim()))
- {
- DataTable dt = ptbll.GetList("Prod_Number='" + this.txtProd_Name.Tag.ToString().Trim() + "'", "ID desc").Tables[0];
- if (dt.Rows[0]["Prod_Name"].ToString().Trim() != this.txtProd_Name.Text.Trim())
- {
- dt = ptbll.GetList("Prod_Name='" + this.txtProd_Name.Text.Trim() + "'").Tables[0];
- if (dt.Rows.Count > 0)
- {
- MessageBoxCustom.Show("商品名称已经存在!");
- return;
- }
- }
- }
- #endregion
- DataTable tbl = ptbll.GetList("Prod_Number='" + this.txtProd_Name.Tag.ToString().Trim() + "'", "ID desc").Tables[0];
- model = ptbll.DataRowToModel(tbl.Rows[0]);
- model.Prod_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtProd_Name.Text.Trim());
- model.Prod_ClassName = this.cmbtreevProdClass.Text.Trim();
- model.Prod_Class = this.cmbtreevProdClass.Tag.ToString();
- if (!string.IsNullOrEmpty(this.cmbtreevProdUnit.Text.Trim()))
- { model.Prod_Unit = this.cmbtreevProdUnit.Text.Trim(); }
- model.Prod_CostPrice = Convert.ToDecimal(this.txtProd_CostPrice.Text);
- model.Prod_SalesPrice = Convert.ToDecimal(this.txtProd_SalesPrice.Text);
- if (!string.IsNullOrEmpty(this.txtProd_PurchasePrice.Text))
- { model.Prod_PurchasePrice = Convert.ToDecimal(this.txtProd_PurchasePrice.Text); }
- if (this.cmbtreevProdIsEnabled.Text.Trim() == "下架")
- { model.Prod_IsEnabled = false; }
- else
- { model.Prod_IsEnabled = true; }
- model.Prod_Remark = this.txtProd_Remark.Text;
- model.Prod_UpdateDateTime = SDateTime.Now;
- model.Prod_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
- model.Prod_Batch = Convert.ToInt32(this.txtProd_Batch.Text);
- model.Prod_AlarmQuantity = Convert.ToInt32(this.txtProd_AlarmQuantity.Text);
- if (this.cmbtreevProdAvailability.Text.Trim() == "不减库存")
- { model.Prod_Availability = 0; }
- else
- { model.Prod_Availability = 1; }
- model.Prod_Thumbnail = PublicCodeClasses.ToHexString(PublicCodeClasses.ImageDatabytes(this.picFam_PhotoAlbum));
- model.Prod_PrintArea = txtProd_PrintArea.Text.Trim();
- model.Prod_Vendor = this.txtProd_Vendor.Text.Trim();
- model.Prod_Width = (int)(Convert.ToSingle(this.txtProd_Width.Text) * 10000);
- model.Prod_Height = (int)(Convert.ToSingle(this.txtProd_Height.Text) * 10000);
- model.Prod_ProductStatus = rdo_Product.Checked ? 1 : 0;
- clist.Add(ptbll.GetUpdateCommandInfo(model));
- }
- if (clist.Count > 0)
- {
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- this.CreateListViewGroup();
- Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage(model.Prod_Thumbnail);
- MessageBoxCustom.Show("保存成功!");
- if (this.txtProd_Name.Tag == null)
- {
- this.cmbtreevProdClassQuery.SelectedNode = null;
- this.cmbtreevProdClassQuery.TextFindTag("全部");
- this.mlistImage.Images.Add(model.Prod_Number.Trim(), img);
- }
- else
- { this.mlistImage.Images.RemoveByKey(model.Prod_Number.Trim()); }
- //清空与刷新
- this.btnReset_Click(this, null);
- this.PublicFunctionRows();
- }
- else
- { MessageBoxCustom.Show("保存失败!"); }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- #endregion
- }
- /// <summary>
- /// 设置商品单位
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnUnit_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new FrmSystemSet();
- frm.TypeName = "AAAAAAG";
- frm.Version = "Version";
- if (frm.ShowDialog() == DialogResult.OK)
- { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAG", this.cmbtreevProdUnit, IsFirstNodeNull: true); }
- }
- /// <summary>
- /// 删除图片
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnPicDelete_Click(object sender, EventArgs e)
- { this.picFam_PhotoAlbum.Image = null; }
- /// <summary>
- /// 上传图片
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnUpload_Click(object sender, EventArgs e)
- {
- openFileDialog1.Filter = "图片文件(*.jpg)|*.jpg|图片文件(*.gif)|*.gif|图片文件(*.bmp)|*.bmp|图片文件(*.png)|*.png";
- openFileDialog1.FileName = "";
- if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- { this.picFam_PhotoAlbum.Image = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(openFileDialog1.FileName.Trim(), 400, 320); }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQuery_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 回车查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtQueryText_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { this.PublicFunctionRows(); }
- }
- /// <summary>
- /// 商品类别查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void cmbtreevProdClassQuery_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- this.btnReset_Click(this, null);
- this.cmbtreevProdClassQuery.SelectedNode = this.cmbtreevProdClassQuery.GetNodeItem_TextToTag(this.cmbtreevProdClassQuery.Text.Trim());
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtProd_PurchasePrice_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- else if (Char.IsPunctuation(e.KeyChar))
- {
- if (e.KeyChar == '.')
- {
- if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtProd_SalesPrice_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- else if (Char.IsPunctuation(e.KeyChar))
- {
- if (e.KeyChar == '.')
- {
- if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtProd_CostPrice_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- else if (Char.IsPunctuation(e.KeyChar))
- {
- if (e.KeyChar == '.')
- {
- if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtProd_Batch_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtProd_AlarmQuantity_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtProd_PrintArea_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- else if (Char.IsPunctuation(e.KeyChar))
- {
- if (e.KeyChar == '.')
- {
- if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- /// <summary>
- /// 商品名称输入限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtProd_Name_TextChanged(object sender, EventArgs e)
- {
- string Prod_Name = txtProd_Name.Text;
- if (!string.IsNullOrEmpty(Prod_Name))
- {
- if (Prod_Name.ToUpper().Contains("\t") ||
- Prod_Name.ToUpper().Contains(":") ||
- Prod_Name.ToUpper().Contains("?") ||
- Prod_Name.ToUpper().Contains("\"") ||
- Prod_Name.ToUpper().Contains("<") ||
- Prod_Name.ToUpper().Contains(">") ||
- Prod_Name.ToUpper().Contains("|") ||
- Prod_Name.ToUpper().Contains("\\") ||
- Prod_Name.ToUpper().Contains("/") ||
- // Prod_Name.ToUpper().Contains("(") ||
- // Prod_Name.ToUpper().Contains(")") ||
- Prod_Name.ToUpper().Contains("*") ||
- Prod_Name.ToUpper().Contains(",") ||
- Prod_Name.ToUpper().Contains('"'))
- {
- MessageBoxCustom.Show("此名称有不合法字符!");
- txtProd_Name.Text = "";
- return;
- }
- }
- }
- /// <summary>
- /// 商品名称输入限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtProd_Name_KeyPress(object sender, KeyPressEventArgs e)
- {
- //2017-04-03 刘工 修改允许商品名中输 ()和. 【】[]
- if (!Char.IsNumber(e.KeyChar)
- && !Char.IsControl(e.KeyChar)
- && !Char.IsLetterOrDigit(e.KeyChar)
- && e.KeyChar != (char)'_'
- && e.KeyChar != (char)' '
- && e.KeyChar != (char)'('
- && e.KeyChar != (char)')'
- && e.KeyChar != (char)'.'
- && e.KeyChar != (char)'['
- && e.KeyChar != (char)']'
- && e.KeyChar != (char)'【'
- && e.KeyChar != (char)'】'
- )
- {
- e.Handled = true;
- }
- }
- /// <summary>
- /// 上架
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkUpperShelves_Click(object sender, EventArgs e)
- {
- this.btnReset_Click(this, null);
- this.chkDownShelves.Checked = false;
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 下架
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkDownShelves_Click(object sender, EventArgs e)
- {
- this.btnReset_Click(this, null);
- this.chkUpperShelves.Checked = false;
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 获取商品名称与商品编号
- /// </summary>
- private void PublicFunctionRows()
- {
- #region 一次性获取
- //string StrOrderBy = "";
- //string StrWhere = this.GetStrWhere();
- //if (StrWhere.Trim().Equals("1=1"))
- //{ StrOrderBy = "Prod_Class desc"; }
- //else
- //{ StrOrderBy = "ID desc"; }
- //this.listViewData_Product.Items.Clear();
- //DataTable newTable = orbll.GetView_Custom("tb_ErpProduct", StrWhere: StrWhere, ShowColumnName: "Prod_Number,Prod_Class,Prod_Name,Prod_Unit,Prod_CostPrice,Prod_SalesPrice,Prod_PurchasePrice,Prod_IsEnabled", filedOrder: StrOrderBy).Tables[0];
- //for (int i = 0; i < newTable.Rows.Count; i++)
- //{
- // ListViewItem lvItem = new ListViewItem();
- // Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage("");
- // this.mlistImage.Images.Add(newTable.Rows[i]["Prod_Number"].ToString().Trim(), img);
- // lvItem.Tag = newTable.Rows[i]["Prod_Number"].ToString().Trim();
- // lvItem.ImageKey = newTable.Rows[i]["Prod_Number"].ToString().Trim();
- // lvItem.Text = newTable.Rows[i]["Prod_Name"].ToString().Trim();
- // ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
- // ListSubItem.Name = "商品名称";
- // ListSubItem.Text = newTable.Rows[i]["Prod_Unit"].ToString().Trim();
- // lvItem.SubItems.Add(ListSubItem);
- // ListSubItem = new ListViewItem.ListViewSubItem();
- // ListSubItem.Name = "进价";
- // ListSubItem.Text = newTable.Rows[i]["Prod_CostPrice"].ToString().Trim();
- // lvItem.SubItems.Add(ListSubItem);
- // ListSubItem = new ListViewItem.ListViewSubItem();
- // ListSubItem.Name = "卖价";
- // ListSubItem.Text = newTable.Rows[i]["Prod_SalesPrice"].ToString().Trim();
- // lvItem.SubItems.Add(ListSubItem);
- // ListSubItem = new ListViewItem.ListViewSubItem();
- // ListSubItem.Name = "制作费";
- // ListSubItem.Text = newTable.Rows[i]["Prod_PurchasePrice"].ToString().Trim();
- // lvItem.SubItems.Add(ListSubItem);
- // ListSubItem = new ListViewItem.ListViewSubItem();
- // ListSubItem.Name = "状态";
- // ListSubItem.Text = Convert.ToBoolean(newTable.Rows[i]["Prod_IsEnabled"]) ? "上架" : "下架";
- // lvItem.SubItems.Add(ListSubItem);
- // if (this.listViewData_Product.Groups.Count > 0)
- // { this.listViewData_Product.Groups[newTable.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
- // this.listViewData_Product.Items.Add(lvItem);
- //}
- #endregion
- this.ucPagerEx1.PageCurrent = 1;
- this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();
- this.ucPagerEx1.Bind();
- }
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
- {
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- pageData.PageIndex = this.ucPagerEx1.PageCurrent;
- pageData.PageSize = this.ucPagerEx1.PageSize;
- this.listViewData_Product.Items.Clear();
- DataTable dt = new DataTable();
- string StrWhere = this.GetStrWhere();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- pageData.TableName = "tb_ErpProduct";
- pageData.QueryCondition = StrWhere;
- pageData.QueryFieldName = "Prod_Number,Prod_Class,Prod_Name,Prod_Unit,Prod_CostPrice,Prod_SalesPrice,Prod_PurchasePrice,Prod_IsEnabled,Prod_Thumbnail,Prod_ProductStatus";
- if (StrWhere.Trim().Equals("1=1"))
- { pageData.OrderStr = "Prod_Class desc,Prod_Number "; }
- else
- { pageData.OrderStr = "ID desc"; }
- pageData.OrderType = 1;
- dt = pageData.QueryDataTable().Tables[0];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (!this.mlistImage.Images.Keys.Contains(dt.Rows[i]["Prod_Number"].ToString().Trim()))
- {
- Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage(dt.Rows[i]["Prod_Thumbnail"].ToString().Trim());
- this.mlistImage.Images.Add(dt.Rows[i]["Prod_Number"].ToString().Trim(), img);
- }
- }
- });
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- ListViewItem lvItem = new ListViewItem();
- lvItem.Tag = dt.Rows[i]["Prod_Number"].ToString().Trim();
- lvItem.ImageKey = dt.Rows[i]["Prod_Number"].ToString().Trim();
- lvItem.Text = dt.Rows[i]["Prod_Name"].ToString().Trim();
- ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "商品名称";
- ListSubItem.Text = dt.Rows[i]["Prod_Unit"].ToString().Trim();
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "进价";
- ListSubItem.Text = dt.Rows[i]["Prod_CostPrice"].ToString().Trim();
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "卖价";
- ListSubItem.Text = dt.Rows[i]["Prod_SalesPrice"].ToString().Trim();
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "制作费";
- ListSubItem.Text = dt.Rows[i]["Prod_PurchasePrice"].ToString().Trim();
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "状态";
- ListSubItem.Text = Convert.ToBoolean(dt.Rows[i]["Prod_IsEnabled"]) ? "上架" : "下架";
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "商品状况";
- ListSubItem.Text = Convert.ToInt32(dt.Rows[i]["prod_ProductStatus"])==1 ? "成品" : "半成品";
- lvItem.SubItems.Add(ListSubItem);
- if (this.listViewData_Product.Groups.Count > 0)
- { this.listViewData_Product.Groups[dt.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
- this.listViewData_Product.Items.Add(lvItem);
- }
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Product);
- this.ucPagerEx1.TbDataSource = dt;
- return pageData.TotalCount;
- }
- /// <summary>
- /// 获取查询条件
- /// </summary>
- /// <returns></returns>
- string GetStrWhere()
- {
- string StrWhere = "1=1";
- if (this.chkUpperShelves.Checked)
- { StrWhere += " and Prod_IsEnabled = 1"; }
- else if (this.chkDownShelves.Checked)
- { StrWhere += " and Prod_IsEnabled = 0"; }
- if (!string.IsNullOrEmpty(this.txtQueryText.Text.Trim()))
- { StrWhere += " and (Prod_Name like '%" + txtQueryText.Text.Trim() + "%' or dbo.fn_ChineseToSpell(Prod_Name) like '%" + txtQueryText.Text.Trim() + "%')"; }
- if (this.cmbtreevProdClassQuery.Text != "全部" && this.cmbtreevProdClassQuery.Text != "")
- {
- if (this.cmbtreevProdClassQuery.Nodes.Count > 0)
- {
- string classString = "'" + this.cmbtreevProdClassQuery.Tag.ToString().Trim() + "',";
- for (int i = 0; i < this.cmbtreevProdClassQuery.SelectedNode.Nodes.Count; i++)
- {
- if (this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes.Count > 0)
- {
- for (int j = 0; j < this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes.Count; j++)
- {
- if (this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes[j].Nodes.Count > 0)
- {
- for (int k = 0; k < this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes[j].Nodes.Count; k++)
- { classString += "'" + this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes[j].Nodes[k].Tag.ToString().Trim() + "',"; }
- }
- else
- { classString += "'" + this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes[j].Tag.ToString().Trim() + "',"; }
- }
- }
- else
- { classString += "'" + this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Tag.ToString().Trim() + "',"; }
- }
- StrWhere += " And Prod_Class in(" + classString.TrimEnd(',') + ")";
- }
- }
- return StrWhere;
- }
- /// <summary>
- /// 查看原图
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void picFam_PhotoAlbum_Click(object sender, EventArgs e)
- {
- if (this.picFam_PhotoAlbum.Image != null)
- {
- LYFZ.Software.MainBusiness.InitialSet.Product.FrmProductPic set = new Product.FrmProductPic();
- set.FrmImage = this.picFam_PhotoAlbum.Image;
- set.ShowDialog();
- }
- }
- }
- }
|