123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.Dresses.DressEntry
- {
- public partial class FrmEntry : LYFZ.Software.UI.Dresses.DressEntry.FrmEntry
- {
- Image imgdelete = null;
- public string Type = "";
- public string Dsfm_DressNumber = "";
- bool bl = false;
- public FrmEntry()
- {
- this.FormClosed += FrmEntry_FormClosed;
- }
- void FrmEntry_FormClosed(object sender, FormClosedEventArgs e)
- {
- if (bl)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- public void ShowImage(string path)
- {
- if ((this.picDsfm_PicturePath.Image != null)) //先释放
- {
- picDsfm_PicturePath.Image.Dispose();
- picDsfm_PicturePath.Image = null;
- }
- if (System.IO.File.Exists(path))
- {
- Image img = Image.FromFile(path); //加载图片
- MemoryStream mstr = new MemoryStream(); //创建新的MemoryStream
- img.Save(mstr, ImageFormat.Gif); // 保存这个对象
- picDsfm_PicturePath.Image = Image.FromStream(mstr); //显示
- img.Dispose();//释放占用
- }
- }
- #region 加载
- protected override void FrmEntry_Shown(object sender, EventArgs e)
- {
- try
- {
- //获取礼服编号
- Random action = new Random();
- txtDsfm_DressNumber.Text = "LF" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMM") + action.Next(100, 1000) + "1";//获取新编号
- BindDsfm_DressType();
- GetDsfm_PlacedRegion();
- #region 修改
- if (Type == "Update")
- {
- if (!string.IsNullOrEmpty(Dsfm_DressNumber))
- {
- txtDsfm_DressNumber.Enabled = false;
- LYFZ.BLL.BLL_ErpDressFrom DressFromBll = new BLL.BLL_ErpDressFrom();
- DataTable dt = DressFromBll.GetList("Dsfm_DressNumber='" + Dsfm_DressNumber + "' ").Tables[0];
- if (dt.Rows.Count > 0)
- {
- txtDsfm_DressNumber.Text = Dsfm_DressNumber;
- CtvDsfm_DressType.TagFindText(dt.Rows[0]["Dsfm_DressType"].ToString());
- cmbDsfm_PlacedRegion.SelectedValue = dt.Rows[0]["Dsfm_PlacedRegion"].ToString();
- txtDsfm_DressName.Text = dt.Rows[0]["Dsfm_DressName"].ToString();
- txtDsfm_DressBrand.Text = dt.Rows[0]["Dsfm_DressBrand"].ToString();
- txtDsfm_DressSize.Text = dt.Rows[0]["Dsfm_DressSize"].ToString();
- txtDsfm_DressQuantity.Text = dt.Rows[0]["Dsfm_DressQuantity"].ToString();
- txtDsfm_CostPrice.Text = dt.Rows[0]["Dsfm_CostPrice"].ToString();
- txtDsfm_RentPrice.Text = dt.Rows[0]["Dsfm_RentPrice"].ToString();
- txtDsfm_SalePrice.Text = dt.Rows[0]["Dsfm_SalePrice"].ToString();
- if (dt.Rows[0]["Dsfm_IsEnabled"].ToString() == "1")
- {
- radDsfm_IsEnabled1.Checked = true;
- }
- else { radDsfm_IsEnabled2.Checked = true; }
- txtDsfm_DressRemark.Text = dt.Rows[0]["Dsfm_DressRemark"].ToString();
- ShowImage(BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + dt.Rows[0]["Dsfm_PicturePath"]);
- }
- }
- }
- #endregion
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 设置
- protected override void btnDsfm_PlacedRegion_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
- LYFZ.BLL.BLL_ErpSystemCategory bll = new BLL.BLL_ErpSystemCategory();
- DataTable dt = bll.GetList("Sc_ClassCode='BEAJBGADBHCCHEFEI'").Tables[0];
- if (dt.Rows.Count > 0)
- {
- set.TypeName = dt.Rows[0]["Sc_ClassCode"].ToString();
- }
- set.Version = "Version";
- if (set.ShowDialog() == DialogResult.OK)
- {
- GetDsfm_PlacedRegion();
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- protected override void btnDsfm_DressType_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
- LYFZ.BLL.BLL_ErpSystemCategory bll = new BLL.BLL_ErpSystemCategory();
- DataTable dt = bll.GetList("Sc_ClassCode='BEAJBGADDCBAHFFA'").Tables[0];
- if (dt.Rows.Count > 0)
- {
- set.TypeName = dt.Rows[0]["Sc_ClassCode"].ToString();
- }
- set.Version = "Version";
- if (set.ShowDialog() == DialogResult.OK)
- {
- BindDsfm_DressType();
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- string PhotoFilePath = "";
- #region 上传
- protected override 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)
- {
- PhotoFilePath = openFileDialog1.FileName;
- //this.picDsfm_PicturePath.Image = Image.FromFile(PhotoFilePath);
- imgdelete = Image.FromFile(PhotoFilePath);
- picDsfm_PicturePath.Image = imgdelete;
- }
- if (Type == "Update")
- {
- lblUpload.Text = PhotoFilePath;
- }
- }
- #endregion
- #region 输入框限制
- protected override void txtDsfm_SalePrice_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- {
- e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
- }
- 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;
- }
- }
- }
- protected override void txtDsfm_RentPrice_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- {
- e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
- }
- 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;
- }
- }
- }
- protected override void txtDsfm_CostPrice_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- {
- e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
- }
- 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;
- }
- }
- }
- protected override void txtDsfm_DressQuantity_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- {
- e.Handled = true;
- }
- }
- #endregion
- #region 关闭
- protected override void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- #region 清空
- protected override void btnClear_Click(object sender, EventArgs e)
- {
- CtvDsfm_DressType.Text = "";
- cmbDsfm_PlacedRegion.Text = "";
- Clear();
- }
- public void Clear()
- {
- //获取礼服编号
- Random action = new Random();
- txtDsfm_DressNumber.Text = "LF" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMM") + action.Next(100, 1000) + "1";//获取新编号
- txtDsfm_DressName.Text = "";
- txtDsfm_DressBrand.Text = "";
- txtDsfm_DressSize.Text = "";
- txtDsfm_DressQuantity.Text = "1";
- txtDsfm_CostPrice.Text = "";
- txtDsfm_RentPrice.Text = "";
- txtDsfm_SalePrice.Text = "";
- radDsfm_IsEnabled1.Checked = true;
- txtDsfm_DressRemark.Text = "";
- PhotoFilePath = "";
- picDsfm_PicturePath.Image = null;
- }
- #endregion
- #region 保存
- protected override void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- DataTable dt = new DataTable();
- LYFZ.BLL.BLL_ErpDressFrom DressBll = new BLL.BLL_ErpDressFrom();
- LYFZ.Model.Model_ErpDressFrom model = new Model.Model_ErpDressFrom();
- #region 输入框
- if (string.IsNullOrEmpty(CtvDsfm_DressType.Text))
- {
- MessageBoxCustom.Show("礼服类别不能为空!");
- return;
- }
- if (string.IsNullOrEmpty(cmbDsfm_PlacedRegion.Text))
- {
- MessageBoxCustom.Show("摆放区域不能为空!");
- return;
- }
- if (string.IsNullOrEmpty(txtDsfm_DressName.Text))
- {
- MessageBoxCustom.Show("礼服名称不能为空!");
- return;
- }
- if (string.IsNullOrEmpty(txtDsfm_DressQuantity.Text))
- {
- MessageBoxCustom.Show("礼服数量不能为空!");
- return;
- }
- if (Convert.ToInt32(txtDsfm_DressQuantity.Text) > 1)
- {
- MessageBoxCustom.Show("礼服数量不能大于1!");
- return;
- }
- if (string.IsNullOrEmpty(txtDsfm_CostPrice.Text))
- {
- MessageBoxCustom.Show("成本价格不能为空!");
- return;
- }
- if (string.IsNullOrEmpty(txtDsfm_RentPrice.Text))
- {
- MessageBoxCustom.Show("出租价格不能为空!");
- return;
- }
- if (string.IsNullOrEmpty(txtDsfm_SalePrice.Text))
- {
- MessageBoxCustom.Show("出售价格不能为空!");
- return;
- }
- /* if (picDsfm_PicturePath.Image == null)
- {
- MessageBoxCustom.Show("礼服图片不能为空!");
- return;
- }*/
- #endregion
- #region 增加
- if (Type == "Add")
- {
- #region 保存
- #region 判断礼服编号是否存在
- if (DressBll.Exists("Dsfm_DressNumber", this.txtDsfm_DressNumber.Text) == true)
- {
- MessageBoxCustom.Show("礼服编号已经存在!请刷新重新获取!");
- return;
- }
- #endregion
- model.Dsfm_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- model.Dsfm_DressNumber = txtDsfm_DressNumber.Text.Trim();
- model.Dsfm_DressType = CtvDsfm_DressType.Tag.ToString();
- model.Dsfm_DressName = txtDsfm_DressName.Text.Trim();
- model.Dsfm_DressBrand = txtDsfm_DressBrand.Text.Trim();
- model.Dsfm_DressSize = txtDsfm_DressSize.Text.Trim();
- model.Dsfm_DressQuantity = Convert.ToInt32(txtDsfm_DressQuantity.Text.Trim());
- model.Dsfm_CostPrice = Convert.ToDecimal(txtDsfm_CostPrice.Text.Trim());
- model.Dsfm_RentPrice = Convert.ToDecimal(txtDsfm_RentPrice.Text.Trim());
- model.Dsfm_SalePrice = Convert.ToDecimal(txtDsfm_SalePrice.Text.Trim());
- if (radDsfm_IsEnabled1.Checked == true)
- {
- model.Dsfm_IsEnabled = "1";
- }
- else { model.Dsfm_IsEnabled = "0"; }
- model.Dsfm_PlacedRegion = cmbDsfm_PlacedRegion.SelectedValue.ToString();
- #region 增加礼服图片
- dt = DressBll.GetList("Dsfm_DressNumber='" + model.Dsfm_DressNumber + "'").Tables[0];
- if (dt.Rows.Count == 0)
- {
- if (!string.IsNullOrEmpty(PhotoFilePath))
- {
- #region 选择图片
- //原图
- string paths = Path.GetExtension(PhotoFilePath);
- string path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")" + paths;
- File.Copy(PhotoFilePath, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
- model.Dsfm_PicturePath = path;
- //缩略图
- path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
- ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(PhotoFilePath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
- #endregion
- }
- else
- {
- #region 默认图片
- //原图
- string paths = ".png";//Path.GetExtension(imgPath);
- string path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")" + paths;
- // File.Copy(imgPath, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
- model.Dsfm_PicturePath = path;
- //缩略图
- // path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
- // ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(imgPath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
- #endregion
- }
- }
- #endregion
- model.Dsfm_DressRemark = txtDsfm_DressRemark.Text.Trim();
- model.Dsfm_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Dsfm_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- if (DressBll.Add(model) == true)
- {
- if (picDsfm_PicturePath.Image != null)
- picDsfm_PicturePath.Image.Dispose();
- MessageBoxCustom.Show("保存成功!");
- bl = true;
- Clear();
- }
- else { MessageBoxCustom.Show("保存失败!"); }
- return;
- #region 数量大于1
- //if (Convert.ToInt32(txtDsfm_DressQuantity.Text) > 1)
- //{
- // int sum = Convert.ToInt32(txtDsfm_DressQuantity.Text);
- // for (int i = 0; i < sum; i++)
- // {
- // model.Dsfm_DressNumber = "LF" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMM") + action.Next(100, 1000) + i;//获取新编号
- // model.Dsfm_DressType = CtvDsfm_DressType.Tag.ToString();
- // model.Dsfm_DressName = txtDsfm_DressName.Text.Trim();
- // model.Dsfm_DressBrand = txtDsfm_DressBrand.Text.Trim();
- // model.Dsfm_DressSize = txtDsfm_DressSize.Text.Trim();
- // model.Dsfm_DressQuantity =1;
- // model.Dsfm_CostPrice = Convert.ToDecimal(txtDsfm_CostPrice.Text.Trim());
- // model.Dsfm_RentPrice = Convert.ToDecimal(txtDsfm_RentPrice.Text.Trim());
- // model.Dsfm_SalePrice = Convert.ToDecimal(txtDsfm_SalePrice.Text.Trim());
- // if (radDsfm_IsEnabled1.Checked == true)
- // {
- // model.Dsfm_IsEnabled = "1";
- // }
- // else { model.Dsfm_IsEnabled = "0"; }
- // model.Dsfm_PlacedRegion = cmbDsfm_PlacedRegion.SelectedValue.ToString();
- // #region 增加礼服图片
- // dt = DressBll.GetList("Dsfm_DressNumber='" + model.Dsfm_DressNumber + "'").Tables[0];
- // if (dt.Rows.Count == 0)
- // {
- // if (!string.IsNullOrEmpty(PhotoFilePath))
- // {
- // #region 选择图片
- // //原图
- // string paths = Path.GetExtension(PhotoFilePath);
- // string path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")" + paths;
- // File.Copy(PhotoFilePath, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
- // model.Dsfm_PicturePath = path;
- // //缩略图
- // path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
- // ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(PhotoFilePath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
- // #endregion
- // }
- // else
- // {
- // #region 默认图片
- // //原图
- // string paths = ".png"; //Path.GetExtension(imgPath);
- // string path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")" + paths;
- // // File.Copy(imgPath, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
- // model.Dsfm_PicturePath = path;
- // //缩略图
- // path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
- // // ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(imgPath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
- // #endregion
- // }
- // }
- // #endregion
- // model.Dsfm_DressRemark = txtDsfm_DressRemark.Text.Trim();
- // model.Dsfm_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- // model.Dsfm_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- // DressBll.Add(model);
- // }
- // if (picDsfm_PicturePath.Image != null)
- // picDsfm_PicturePath.Image.Dispose();
- // MessageBoxCustom.Show("保存成功!");
- // bl = true;
- // Clear();
- //}
- #endregion
- #endregion
- }
- #endregion
- #region 修改
- if (Type == "Update")
- {
- dt = new DataTable();
- dt = DressBll.GetList("Dsfm_DressNumber='" + Dsfm_DressNumber + "'").Tables[0];
- int Id = Convert.ToInt32(dt.Rows[0]["ID"]);
- model = DressBll.GetModel(Id);
- model.Dsfm_DressType = CtvDsfm_DressType.Tag.ToString();
- model.Dsfm_DressName = txtDsfm_DressName.Text.Trim();
- model.Dsfm_DressBrand = txtDsfm_DressBrand.Text.Trim();
- model.Dsfm_DressSize = txtDsfm_DressSize.Text.Trim();
- model.Dsfm_DressQuantity = Convert.ToInt32(txtDsfm_DressQuantity.Text.Trim());
- model.Dsfm_CostPrice = Convert.ToDecimal(txtDsfm_CostPrice.Text.Trim());
- model.Dsfm_RentPrice = Convert.ToDecimal(txtDsfm_RentPrice.Text.Trim());
- model.Dsfm_SalePrice = Convert.ToDecimal(txtDsfm_SalePrice.Text.Trim());
- if (radDsfm_IsEnabled1.Checked == true)
- {
- model.Dsfm_IsEnabled = "1";
- }
- else { model.Dsfm_IsEnabled = "0"; }
- model.Dsfm_PlacedRegion = cmbDsfm_PlacedRegion.SelectedValue.ToString();
- model.Dsfm_DressRemark = txtDsfm_DressRemark.Text.Trim();
- model.Dsfm_UpdateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Dsfm_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- #region 修改图片
- if (!string.IsNullOrEmpty(lblUpload.Text))
- {
- string Dsfm_PicturePath = dt.Rows[0]["Dsfm_PicturePath"].ToString();
- //删除原图
- File.Delete((BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + dt.Rows[0]["Dsfm_PicturePath"]));
- //删除缩略图
- char[] pathst = Path.GetExtension(Dsfm_PicturePath).ToCharArray();
- Dsfm_PicturePath = Dsfm_PicturePath.TrimEnd(pathst);
- File.Delete(BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + Dsfm_PicturePath + "&Small" + Path.GetExtension(dt.Rows[0]["Dsfm_PicturePath"].ToString()));
- //增加原图
- string paths = Path.GetExtension(lblUpload.Text);
- string path = txtDsfm_DressName.Text + "(" + Dsfm_DressNumber + ")" + paths;
- File.Copy(lblUpload.Text, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
- model.Dsfm_PicturePath = path;
- //增加缩略图
- path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
- ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(PhotoFilePath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
- }
- #endregion
- if (DressBll.Update(model) == true)
- {
- MessageBoxCustom.Show("保存成功!");
- bl = true;
- this.Close();
- }
- else { MessageBoxCustom.Show("保存失败!"); }
- }
- #endregion
- }
- 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++)
- {
- 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>
- public void GetDsfm_PlacedRegion()
- {
- DataTable dt = new DataTable();
- #region 绑定摆放区域
- LYFZ.BLL.BLL_ErpSystemCategory SystemCategorybll = new BLL.BLL_ErpSystemCategory();
- DataTable dt2 = new DataTable();
- DataRow dr = dt.NewRow();
- dt2 = SystemCategorybll.GetList("Sc_ClassCode='BEAJBGADBHCCHEFEI'").Tables[0];
- dt = SystemCategorybll.GetList("Sc_ClassParentID=" + dt2.Rows[0]["ID"] + "").Tables[0];
- cmbDsfm_PlacedRegion.DataSource = dt;
- this.cmbDsfm_PlacedRegion.ValueMember = "Sc_ClassCode";
- this.cmbDsfm_PlacedRegion.DisplayMember = "Sc_ClassName";
- dr = dt.NewRow();
- dr["Sc_ClassCode"] = "-1";
- dr["Sc_ClassName"] = "";
- dt.Rows.InsertAt(dr, 0);
- this.cmbDsfm_PlacedRegion.SelectedIndex = 0;
- #endregion
- }
- #endregion
- #region 礼服名称输入限制
- protected override void txtDsfm_DressName_TextChanged(object sender, EventArgs e)
- {
- try
- {
- string Prod_Name = txtDsfm_DressName.Text;
- if (!string.IsNullOrEmpty(Prod_Name))
- {
- if (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("此名称有不合法字符!");
- txtDsfm_DressName.Text = "";
- return;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 获取新的礼服编号
- protected override void btnRefresh_Click(object sender, EventArgs e)
- {
- //获取礼服编号
- Random action = new Random();
- txtDsfm_DressNumber.Text = "LF" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMM") + action.Next(100, 1000) + "1";//获取新编号
- }
- #endregion
- }
- }
|