123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801 |
- 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.IO;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.InitialSet
- {
- public partial class FrmAttractionsSet : LYFZ.Software.UI.InitialSet.FrmAttractionsSet
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpTheScenery tsbll = new BLL.BLL_ErpTheScenery();
- LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory();
- LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
- LYFZ.BLL.BLL_ErpSystemLogs systemLogsBll = new BLL.BLL_ErpSystemLogs();
- public FrmAttractionsSet(string StrType = "0")
- {
- if (!string.IsNullOrEmpty(StrType))
- { this.StrPackagesType = Convert.ToInt32(StrType); }
- else
- { this.StrPackagesType = 0; }
- this.dgv.CellMouseDoubleClick += dgv_CellMouseDoubleClick;
- this.btnBrowse.Click += btnBrowse_Click;
- this.lstvData.MouseDoubleClick += lstvData_MouseDoubleClick;
- this.btnDeletePhoto.Click += btnDeletePhoto_Click;
- // 是否是管理员admin账号;
- if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Account.ToLower() == "admin")
- {
- this.btnUpdateScenery.Click += BtnUpdateScenery_Click;
- }
- else
- {
- this.btnUpdateScenery.Visible = false;
- }
- }
- private void BtnUpdateScenery_Click(object sender, EventArgs e)
- {
- MessageBoxCustom.Show("更新前, 请做好数据库的备份!");
- string strUpdateSQL = " with t as ( select " +
- "Ordpg_Number as 订单号, "+
- "Ordpg_Sights as 订单景点名, "+
- "Ordpg_SightsLevel as 订单景点比例, "+
- "Tsc_Rating as 系统景点比重 from"+
- "[tb_ErpOrdersPhotography] left join[tb_ErpTheScenery] on Tsc_Name = Ordpg_Sights "+
- "where Ordpg_SightsLevel<> Tsc_Rating or Ordpg_SightsLevel is null "+
- ")update t set 订单景点比例 = 系统景点比重";
- if ( LYFZ.Helper.SQLHelper.ExecuteSql(strUpdateSQL) >= 0 )
- MessageBoxCustom.Show("更新成功!");
- }
- /// <summary>
- /// 套系大类类型(0:订单景点,1:礼包景点)
- /// </summary>
- public int StrPackagesType;
- /// <summary>
- /// 景点类型(0:景点,1:次数)
- /// </summary>
- public string StrSightsType;
- string StrTableName = "tb_ErpTheScenery Left Join tb_ErpSystemCategory on Sc_ClassCode = Tsc_Rating";
- string StrColumns = "tb_ErpTheScenery.ID,Tsc_Name,Tsc_Type,Tcs_Category,Tsc_PackagesMainClass,Tsc_Rating,Sc_ClassName AS Tsc_RatingName,Tsc_Introduction,Tsc_DetailsOf,Tsc_Address,Tsc_CostPrice,Tsc_SalesPrice," +
- "Tsc_Remark,Tsc_Thumbnail,Tsc_PhotoAlbum,Tsc_IsDisable,Tsc_CreateDatetime,Tsc_CreateName,Tsc_UpdateDatetime,Tsc_UpdateName,CASE Tcs_Category WHEN 0 THEN '内景' ELSE '外景' END AS Tcs_CategoryName,case when Tsc_IsDisable = 0 then '显示' else '隐藏' end Tsc_IsDisableName";
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void FrmAttractionsSet_Load(object sender, EventArgs e)
- {
- if (this.StrPackagesType == 0)
- { this.Text = "拍摄名称设置"; }
- else
- { this.Text = "拍摄名称(礼包)设置"; }
- if (!string.IsNullOrEmpty(this.StrSightsType))
- {
- if (this.StrSightsType.ToString() == "0")
- {
- this.tab.TabPages.RemoveAt(1);
- this.GetAttractions();
- }
- if (this.StrSightsType.ToString() == "1")
- {
- this.tab.TabPages.RemoveAt(0);
- this.GetAttractionsCs();
- }
- }
- else
- {
- this.GetAttractions();
- this.GetAttractionsCs();
- }
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevIsDisable, "0:显示,1:隐藏", IsSplit: true);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevIsDisable2, "0:显示,1:隐藏", IsSplit: true);
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void FrmAttractionsSet_Shown(object sender, EventArgs e)
- {
- if (this.dgv.SelectedRows.Count == 0 || this.dgv2.SelectedRows.Count == 0)
- {
- this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.AttractionsCompetence, CustomAttributes.OperatingAuthority.Add);
- this.btnAdd.Enabled = this.btnSave.Enabled;
- this.btnSave2.Enabled = this.btnSave.Enabled;
- this.btnAdd2.Enabled = this.btnSave.Enabled;
- }
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.AttractionsCompetence, CustomAttributes.OperatingAuthority.Delete);
- this.btnDelete2.Enabled = this.btnDelete.Enabled;
- //绑定景点等级
- DataTable dt2 = scbll.GetList("Sc_ClassCode = 'BEBBBCADFEBEJBGD'").Tables[0];
- if (dt2.Rows.Count > 0)
- {
- DataTable dt = scbll.GetList("Sc_ClassParentID=" + dt2.Rows[0]["ID"] + "", "Id asc").Tables[0];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- this.cmbTsc_Rating.Items.Add(new ListItem(dt.Rows[i]["Sc_ClassName"].ToString(), dt.Rows[i]["Sc_ClassCode"]));
- this.cmbTsc_Rating2.Items.Add(new ListItem(dt.Rows[i]["Sc_ClassName"].ToString(), dt.Rows[i]["Sc_ClassCode"]));
- }
- }
- this.ImageList1.ColorDepth = ColorDepth.Depth32Bit;
- this.ImageList1.ImageSize = new Size(65, 65);
- this.lstvData.View = View.LargeIcon;
- this.lstvData.LargeImageList = this.ImageList1;
- this.GetPhotoData(this.txtTsc_Name.Text.Trim());
- }
- /// <summary>
- /// 获取景点数据
- /// </summary>
- public void GetAttractions()
- {
- string StrWhere = " And Tsc_PackagesMainClass = '" + this.StrPackagesType + "'";
- DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: "Tsc_Type = '0'", ShowColumnName: StrColumns).Tables[0];
- //DataTable dt = tsbll.View_ErpTheScenery("Tsc_Type = '0' And Tsc_PackagesMainClass = '"+this.StrPackagesType+"'").Tables[0];
- this.dgv.AutoGenerateColumns = false;
- this.dgv.DataSource = dt;
- this.dgv.ClearSelection();
- }
- /// <summary>
- /// 获取次数数据
- /// </summary>
- public void GetAttractionsCs()
- {
- string StrWhere = " And Tsc_PackagesMainClass = '" + this.StrPackagesType + "'";
- DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: "Tsc_Type='1'", ShowColumnName: StrColumns).Tables[0];
- //DataTable dt = tsbll.View_ErpTheScenery("Tsc_Type='1' And Tsc_PackagesMainClass = '" + this.StrPackagesType + "'").Tables[0];
- this.dgv2.AutoGenerateColumns = false;
- this.dgv2.DataSource = dt;
- this.dgv2.ClearSelection();
- }
- /// <summary>
- /// 显示控件单击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgv_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- try
- {
- if (this.dgv.SelectedRows.Count > 0)
- {
- //更新赋值
- string ID = this.dgv.CurrentRow.Cells["ID"].Value.ToString();
- DataTable dt = tsbll.GetList("ID='" + ID + "'").Tables[0];
- this.txtTsc_Name.Text = dt.Rows[0]["Tsc_Name"].ToString();
- this.txtTsc_Name.Tag = ID;
- this.txtTsc_Address.Text = dt.Rows[0]["Tsc_Address"].ToString();
- this.txtTsc_CostPrice.Text = dt.Rows[0]["Tsc_CostPrice"].ToString();
- this.txtTsc_SalesPrice.Text = dt.Rows[0]["Tsc_SalesPrice"].ToString();
- this.txtTsc_Remark.Text = dt.Rows[0]["Tsc_Remark"].ToString();
- this.cmbtreevIsDisable.TagFindText(dt.Rows[0]["Tsc_IsDisable"].ToString().Trim());
- this.cmbTsc_Rating.SelectedItem = ListItem.ValueFindByText(this.cmbTsc_Rating, dt.Rows[0]["Tsc_Rating"].ToString());
- if (Convert.ToInt32(dt.Rows[0]["Tcs_Category"]) == 0)
- { this.cmbTcs_Category.Text = "内景"; }
- else
- { this.cmbTcs_Category.Text = "外景"; }
- this.btnSave.Text = " 修 改";
- //更新商品权限
- this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.AttractionsCompetence, CustomAttributes.OperatingAuthority.Update);
- this.GetPhotoData(this.txtTsc_Name.Text.Trim());
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 保存景点
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSave_Click(object sender, EventArgs e)
- {
- #region 判断资料不能为空
- if (string.IsNullOrEmpty(this.txtTsc_Name.Text.Trim()))
- { MessageBoxCustom.Show("景点名称不能为空!"); this.txtTsc_Name.Focus(); return; }
- if (string.IsNullOrEmpty(this.txtTsc_CostPrice.Text.Trim()))
- { MessageBoxCustom.Show("景点成本价不能为空!"); return; }
- if (string.IsNullOrEmpty(this.txtTsc_SalesPrice.Text.Trim()))
- { MessageBoxCustom.Show("景点摄影报价不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbTsc_Rating.Text.Trim()))
- { MessageBoxCustom.Show("景点等级不能为空!"); return; }
- if (string.IsNullOrEmpty(cmbTcs_Category.Text.Trim()))
- { MessageBoxCustom.Show("景点所属类别不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbtreevIsDisable.Text.Trim()))
- { MessageBoxCustom.Show("景点是否启用不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbtreevIsDisable.Text.Trim()))
- { MessageBoxCustom.Show("景点是否启用不能为空!"); return; }
- if (this.txtTsc_Name.Text.Trim().Length > 20)
- { MessageBoxCustom.Show("景点名称长度不能超过20字!"); return; }
- #endregion
- #region 增加、修改
- try
- {
- if (this.txtTsc_Name.Tag == null)
- {
- #region 判断景点名称是否存在
- //if (tsbll.Exists("Tsc_Name", this.txtTsc_Name.Text) == true)
- if (tsbll.GetList("Tsc_Name = '" + this.txtTsc_Name.Text.Trim() + "' and Tsc_Type = '0'").Tables[0].Rows.Count > 0)
- {
- MessageBoxCustom.Show("景点名称已经存在!");
- this.txtTsc_Name.Text = "";
- this.txtTsc_Name.Focus();
- return;
- }
- #endregion
- LYFZ.Model.Model_ErpTheScenery model = new Model.Model_ErpTheScenery();
- model.Tsc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- model.Tsc_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtTsc_Name.Text.Trim());
- model.Tsc_Type = "0";
- if (cmbTcs_Category.Text == "内景")
- { model.Tcs_Category = 0; }
- else
- { model.Tcs_Category = 1; }
- model.Tsc_PackagesMainClass = this.StrPackagesType;
- model.Tsc_Rating = ((ListItem)this.cmbTsc_Rating.SelectedItem).StrValue.ToString().Trim();
- model.Tsc_Address = txtTsc_Address.Text;
- model.Tsc_CostPrice = Convert.ToDecimal(txtTsc_CostPrice.Text);
- model.Tsc_SalesPrice = Convert.ToDecimal(txtTsc_SalesPrice.Text);
- model.Tsc_IsDisable = this.cmbtreevIsDisable.Tag.ToString().Trim();
- model.Tsc_Remark = txtTsc_Remark.Text;
- model.Tsc_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Tsc_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- if (!tsbll.Add(model))
- { MessageBoxCustom.Show("保存失败!"); return; }
- }
- else
- {
- #region 判断景点名称是否存在
- if (!string.IsNullOrEmpty(txtTsc_Name.Text.Trim()))
- {
- DataTable dt = tsbll.GetList("ID=" + dgv.CurrentRow.Cells["ID"].Value.ToString() + "", "ID desc").Tables[0];
- string Tsc_Name = dt.Rows[0]["Tsc_Name"].ToString();
- if (Tsc_Name != txtTsc_Name.Text.Trim())
- {
- dt = tsbll.GetList("Tsc_Name='" + txtTsc_Name.Text.Trim() + "'").Tables[0];
- if (dt.Rows.Count > 0)
- { MessageBoxCustom.Show("景点名称已经存在!"); return; }
- }
- }
- #endregion
- LYFZ.Model.Model_ErpTheScenery model = tsbll.GetModel(Convert.ToInt32(this.txtTsc_Name.Tag));
- model.Tsc_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtTsc_Name.Text.Trim());
- if (cmbTcs_Category.Text == "内景")
- { model.Tcs_Category = 0; }
- else
- { model.Tcs_Category = 1; }
- model.Tsc_Rating = ((ListItem)this.cmbTsc_Rating.SelectedItem).StrValue.ToString().Trim();
- model.Tsc_Address = txtTsc_Address.Text;
- model.Tsc_CostPrice = Convert.ToDecimal(txtTsc_CostPrice.Text);
- model.Tsc_SalesPrice = Convert.ToDecimal(txtTsc_SalesPrice.Text);
- model.Tsc_Remark = txtTsc_Remark.Text;
- model.Tsc_IsDisable = this.cmbtreevIsDisable.Tag.ToString().Trim();
- model.Tsc_UpdateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Tsc_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- if (!tsbll.Update(model))
- { MessageBoxCustom.Show("保存失败!"); return; }
- }
- this.GetAttractions();
- this.btnAdd_Click(this, null);
- MessageBoxCustom.Show("保存成功!");
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- #endregion
- }
- /// <summary>
- /// 删除景点
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnDelete_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgv.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
- //if (Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value) == 1)
- //{ MessageBoxCustom.Show("此景点不能删除!"); return; }
- int id = Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value);
- DataTable dt = orbll.GetView_Custom("tb_ErpTheScenery", StrWhere: "ID = '" + id + "'", ShowColumnName: "Tsc_Name").Tables[0];
- if (dt.Rows.Count > 0)
- {
- DataTable tbl = orbll.GetView_Custom("tb_ErpOrdersPhotography", StrWhere: "Ordpg_Sights = '" + dt.Rows[0]["Tsc_Name"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
- if (tbl.Rows.Count > 0)
- { MessageBoxCustom.Show("此景点已有订单选中,不能删除!"); return; }
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- if (tsbll.Delete(id) == true)
- {
- #region 写入操作日志
- string logsContent = "删除景点名称:" + txtTsc_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
- #region 删除相片
- List<string> strList = new List<string>();
- for (int i = 0; i < lstvData.Items.Count; i++)
- { strList.Add(lstvData.Items[i].Tag.ToString().Trim()); }
- for (int i = 0; i < lstvData.Items.Count; i++)
- {
- string[] StrArray = lstvData.Items[i].Tag.ToString().Trim().Split('_');
- string StrSmall = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DecryptDES(StrArray[1].Trim());
- string StrOriginal = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DecryptDES(StrArray[0].Trim());
- try
- {
- if (System.IO.File.Exists(StrOriginal))
- { System.IO.File.Delete(StrOriginal); }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); break; }
- try
- {
- if (System.IO.File.Exists(StrSmall))
- { System.IO.File.Delete(StrSmall); }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); break; }
- }
- this.GetPhotoData(this.txtTsc_Name.Text.Trim());
- #endregion
- MessageBoxCustom.Show("删除成功!");
- this.btnAdd_Click(this, null);
- }
- else
- { MessageBoxCustom.Show("删除失败!"); }
- this.GetAttractions();
- }
- }
- else
- { MessageBoxCustom.Show("景点已不存在或已被删除!"); }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 设置文本框
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtTsc_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 (((TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- /// <summary>
- /// 设置文本框
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtTsc_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 (((TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- /// <summary>
- /// 重置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnAdd_Click(object sender, EventArgs e)
- {
- this.txtTsc_Name.Text = "";
- this.txtTsc_Name.Tag = null;
- this.txtTsc_Address.Text = "";
- this.txtTsc_CostPrice.Text = "";
- this.txtTsc_SalesPrice.Text = "";
- this.txtTsc_Remark.Text = "";
- this.cmbTcs_Category.Text = "";
- this.cmbTsc_Rating.SelectedItem = null;
- this.cmbtreevIsDisable.TagFindText("0");
- this.btnSave.Text = " 新 增";
- this.ImageList1.Images.Clear();
- this.lstvData.Items.Clear();
- this.txtTsc_Name.Focus();
- }
- /// <summary>
- /// 根目录
- /// </summary>
- private string PPath = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SightsDirectoryPath();
- ImageList ImageList1 = new ImageList();
- void GetPhotoData(string StrStyleName)
- {
- if (!string.IsNullOrEmpty(StrStyleName))
- {
- this.ImageList1.Images.Clear();
- this.lstvData.Items.Clear();
- string StrPath = PPath + "\\Small";
- if (System.IO.Directory.Exists(StrPath))
- {
- string[] fileNames = Directory.GetFiles(StrPath);
- for (int i = 0; i < fileNames.Length; i++)
- {
- string[] StrPhotoNameArray = System.IO.Path.GetFileNameWithoutExtension(fileNames[i].Trim()).Split('_');
- if (StrPhotoNameArray[0].Trim() == StrStyleName.Trim() || StrStyleName.Trim() == "全部")
- {
- Image img = Image.FromStream(new MemoryStream(System.IO.File.ReadAllBytes(fileNames[i].Trim())));
- string StrPhotoName = System.IO.Path.GetFileNameWithoutExtension(fileNames[i].Trim());
- this.ImageList1.Images.Add(StrPhotoName, img);
- ListViewItem lvi = new ListViewItem();
- lvi.ImageKey = StrPhotoName;
- lvi.Text = StrPhotoNameArray[0].Trim() + "_" + StrPhotoNameArray[1].Trim();
- lvi.Tag = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.EncryptDES(fileNames[i].Trim().Replace("_Small_", "_Original_").Replace("Small\\", "")) + "_" + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.EncryptDES(fileNames[i].Trim());//小图路径
- lvi.ToolTipText = lvi.Text;
- this.lstvData.Items.Add(lvi);
- }
- }
- }
- }
- }
- char[] StrListChar = ",./;'*-+`~!#$%^&<>?|:".ToCharArray();
- /// <summary>
- /// 上传相片
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnBrowse_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.txtTsc_Name.Tag == null)
- { MessageBoxCustom.Show("景点:" + this.txtTsc_Name.Text.Trim() + " 尚未保存,不能上传相片!"); return; }
- if (string.IsNullOrEmpty(this.txtTsc_Name.Text) || this.txtTsc_Name.Text.Trim() == "全部")
- { MessageBoxCustom.Show("请选择当前景点!"); return; }
- OpenFileDialog openFileDialog1 = new OpenFileDialog();
- openFileDialog1.FileName = "";
- string[] SplitArray = sgbll.GetSystemConfigure("Sconfig_Value", "ImageType").Tables[0].Rows[0]["Sconfig_Value"].ToString().Trim().Split('|');
- string SplitStr = "图片文件|";
- for (int i = 0; i < SplitArray.Length; i++)
- {
- if (i > 0)
- { SplitStr += ";" + "*" + SplitArray[i].Trim(); }
- else
- { SplitStr += "*" + SplitArray[i].Trim(); }
- }
- openFileDialog1.Filter = SplitStr;
- openFileDialog1.Multiselect = true;
- openFileDialog1.FilterIndex = 2;
- if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
- {
- string[] FileNames = openFileDialog1.FileNames;
- string StrPhotoName = this.txtTsc_Name.Text.Trim();
- if (FileNames.Length > 20)
- { MessageBoxCustom.Show("每个景点上传相片最多不能超过20张"); return; }
- if (FileNames.Length + this.lstvData.Items.Count > 20)
- { MessageBoxCustom.Show("每个景点上传相片最多不能超过20张"); return; }
- for (int i = 0; i < FileNames.Length; i++)
- {
- string StrFileNameName = System.IO.Path.GetFileNameWithoutExtension(FileNames[i].Trim());
- for (int j = 0; j < this.StrListChar.Length; j++)
- {
- if (StrFileNameName.Trim().Contains(this.StrListChar[j].ToString().Trim()))
- { MessageBoxCustom.Show("要上传的相片‘" + StrFileNameName + "’中不能含有非法字符‘" + this.StrListChar[j].ToString().Trim() + "’"); return; }
- }
- }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- try
- {
- backgroundWorker.ReportProgress(0, "正在上传,请稍等...");
- for (int i = 0; i < FileNames.Length; i++)
- {
- string StrGuid = LYFZ.WinAPI.CustomPublicMethod.GenerateId().ToString();
- if (!System.IO.Directory.Exists(PPath))
- {
- try
- { System.IO.Directory.CreateDirectory(PPath); }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); return; }
- }
- string StrFileNameName = System.IO.Path.GetFileNameWithoutExtension(FileNames[i].Trim());
- string StrBigPicture = PPath + "\\" + StrPhotoName + "_" + StrFileNameName + "_Original_" + StrGuid + ".jpg";
- string StrSmallMapPath = PPath + "\\" + "Small";
- if (!System.IO.Directory.Exists(StrSmallMapPath))
- {
- try
- { System.IO.Directory.CreateDirectory(StrSmallMapPath); }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); return; }
- }
- StrSmallMapPath += "\\" + StrPhotoName + "_" + StrFileNameName + "_Small_" + StrGuid + ".jpg";
- //LYFZ.BLL.SelectPhotoHandling.SaveIamge(new Bitmap(Image.FromFile(FileNames[i].Trim())), StrBigPicture);
- LYFZ.BLL.SelectPhotoHandling.SaveIamge(LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(FileNames[i].Trim(), 1920, 1080), StrBigPicture);
- LYFZ.BLL.SelectPhotoHandling.SaveIamge(LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(FileNames[i].Trim(), 600, 400), StrSmallMapPath);
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message, backgroundWorker: backgroundWorker); }
- });
- this.GetPhotoData(this.txtTsc_Name.Text.Trim());
- }
- }
- catch { }
- }
- /// <summary>
- /// 删除相片
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDeletePhoto_Click(object sender, EventArgs e)
- {
- List<ListViewItem> delList = new List<ListViewItem>();
- List<string> StrSelectPathList = new List<string>();
- for (int i = 0; i < this.lstvData.SelectedItems.Count; i++)
- {
- delList.Add(this.lstvData.SelectedItems[i]);
- StrSelectPathList.Add(this.lstvData.SelectedItems[i].ImageKey.ToString().Trim() + ".jpg");
- }
- if (MessageBoxCustom.Show("您确定要删除所选择的相片吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- for (int i = 0; i < StrSelectPathList.Count; i++)
- {
- string StrBigPicture = PPath + "\\" + StrSelectPathList[i].Trim();
- if (File.Exists(StrBigPicture))
- {
- backgroundWorker.ReportProgress(0, "正在删除大图...");
- File.Delete(StrBigPicture);
- }
- string StrSmallMapPath = PPath + "\\" + "Small" + "\\" + StrSelectPathList[i].Trim();
- if (File.Exists(StrSmallMapPath))
- {
- backgroundWorker.ReportProgress(0, "正在删除小图...");
- File.Delete(StrSmallMapPath);
- }
- }
- try
- {
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
- {
- for (int i = 0; i < delList.Count; i++)
- { this.lstvData.Items.Remove(delList[i]); }
- }));
- }
- catch
- { }
- });
- }
- /// <summary>
- /// 双击查看
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void lstvData_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (lstvData.SelectedItems != null && lstvData.SelectedItems.Count > 0)
- {
- string[] StrArray = lstvData.SelectedItems[0].Tag.ToString().Trim().Split('_');
- Image img = Image.FromStream(new MemoryStream(System.IO.File.ReadAllBytes(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DecryptDES(StrArray[1].Trim()))));
- LYFZ.Software.MainBusiness.InitialSet.Product.FrmProductPic frm = new InitialSet.Product.FrmProductPic();
- frm.FrmImage = img;
- frm.WindowState = FormWindowState.Maximized;
- frm.ShowDialog();
- }
- }
- /// <summary>
- /// 新增次数
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnAdd2_Click(object sender, EventArgs e)
- { this.BindClear2(); }
- /// <summary>
- /// 清空
- /// </summary>
- public void BindClear2()
- {
- this.txtTsc_Name2.Text = "";
- this.txtTsc_Name2.Tag = null;
- this.txtTsc_Remark2.Text = "";
- this.cmbTsc_Rating2.SelectedItem = null;
- this.cmbTcs_Category2.Text = "";
- this.cmbtreevIsDisable2.TagFindText("0");
- this.btnSave2.Text = " 新 增";
- this.txtTsc_Name2.Focus();
- }
- /// <summary>
- /// 显示控件单击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgv2_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgv2.SelectedRows.Count > 0)
- {
- //更新赋值
- string ID = this.dgv2.CurrentRow.Cells["ID2"].Value.ToString();
- DataTable dt = tsbll.GetList("ID=" + ID + "").Tables[0];
- this.txtTsc_Name2.Text = dt.Rows[0]["Tsc_Name"].ToString();
- this.txtTsc_Name2.Tag = ID;
- this.cmbtreevIsDisable2.TagFindText(dt.Rows[0]["Tsc_IsDisable"].ToString().Trim());
- this.txtTsc_Remark2.Text = dt.Rows[0]["Tsc_Remark"].ToString();
- this.cmbTsc_Rating2.SelectedItem = ListItem.ValueFindByText(this.cmbTsc_Rating2, dt.Rows[0]["Tsc_Rating"].ToString());
- if (Convert.ToInt32(dt.Rows[0]["Tcs_Category"]) == 0)
- { this.cmbTcs_Category2.Text = "内景"; }
- else
- { this.cmbTcs_Category2.Text = "外景"; }
- this.btnSave2.Text = " 修 改";
- // 更新商品权限
- this.btnSave2.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.AttractionsCompetence, CustomAttributes.OperatingAuthority.Update);
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnClose2_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnDelete2_Click(object sender, EventArgs e)
- {
- if (this.dgv2.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
- //if (Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value) == 1)
- //{ MessageBoxCustom.Show("此景点不能删除!"); return; }
- int id = Convert.ToInt32(this.dgv2.CurrentRow.Cells["ID2"].Value);
- DataTable dt = orbll.GetView_Custom("tb_ErpTheScenery", StrWhere: "ID = '" + id + "'", ShowColumnName: "Tsc_Name").Tables[0];
- if (dt.Rows.Count > 0)
- {
- DataTable tbl = orbll.GetView_Custom("tb_ErpOrdersPhotography", StrWhere: "Ordpg_Sights = '" + dt.Rows[0]["Tsc_Name"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
- if (tbl.Rows.Count > 0)
- { MessageBoxCustom.Show("此景点已有订单选中,不能删除!"); return; }
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- if (tsbll.Delete(id) == true)
- {
- string logsContent = "删除次数名称:" + txtTsc_Name2.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);
- MessageBoxCustom.Show("删除成功!");
- this.BindClear2();
- }
- else
- { MessageBoxCustom.Show("删除失败!"); }
- this.GetAttractionsCs();
- }
- }
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSave2_Click(object sender, EventArgs e)
- {
- #region 判断资料不能为空
- if (string.IsNullOrEmpty(this.txtTsc_Name2.Text.Trim()))
- { MessageBoxCustom.Show("次数名称不能为空!"); this.txtTsc_Name2.Focus(); return; }
- if (string.IsNullOrEmpty(this.cmbTsc_Rating2.Text.Trim()))
- { MessageBoxCustom.Show("次数等级不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbTcs_Category2.Text.Trim()))
- { MessageBoxCustom.Show("次数所属类型不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbtreevIsDisable2.Text.Trim()))
- { MessageBoxCustom.Show("次数是否启用不能为空!"); return; }
- if (this.txtTsc_Name2.Text.Trim().Length > 20)
- { MessageBoxCustom.Show("次数名称长度不能超过20字!"); return; }
- #endregion
- #region 增加、修改
- try
- {
- if (this.txtTsc_Name2.Tag == null)
- {
- #region 判断景点名称是否存在
- //if (tsbll.Exists("Tsc_Name", this.txtTsc_Name2.Text) == true)
- if (tsbll.GetList("Tsc_Name = '" + this.txtTsc_Name2.Text.Trim() + "' and Tsc_Type = '1'").Tables[0].Rows.Count > 0)
- {
- MessageBoxCustom.Show("次数名称已经存在!");
- this.txtTsc_Name2.Text = "";
- this.txtTsc_Name2.Focus();
- return;
- }
- #endregion
- LYFZ.Model.Model_ErpTheScenery model = new Model.Model_ErpTheScenery();
- model.Tsc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- model.Tsc_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtTsc_Name2.Text.Trim());
- model.Tsc_Type = "1";
- if (cmbTcs_Category2.Text == "内景")
- { model.Tcs_Category = 0; }
- else
- { model.Tcs_Category = 1; }
- model.Tsc_PackagesMainClass = this.StrPackagesType;
- model.Tsc_Rating = ((ListItem)this.cmbTsc_Rating2.SelectedItem).StrValue.ToString().Trim();
- model.Tsc_IsDisable = this.cmbtreevIsDisable2.Tag.ToString().Trim();
- model.Tsc_Remark = txtTsc_Remark2.Text;
- model.Tsc_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Tsc_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- if (!tsbll.Add(model))
- { MessageBoxCustom.Show("保存失败!"); return; }
- }
- else
- {
- #region 判断景点名称是否存在
- if (!string.IsNullOrEmpty(txtTsc_Name2.Text))
- {
- DataTable dt = tsbll.GetList("ID=" + dgv2.CurrentRow.Cells["ID2"].Value.ToString() + "", "ID desc").Tables[0];
- string Tsc_Name = dt.Rows[0]["Tsc_Name"].ToString();
- if (Tsc_Name != txtTsc_Name2.Text)
- {
- dt = tsbll.GetList("Tsc_Name='" + txtTsc_Name2.Text + "'").Tables[0];
- if (dt.Rows.Count > 0)
- { MessageBoxCustom.Show("景点名称已经存在!"); return; }
- }
- }
- #endregion
- LYFZ.Model.Model_ErpTheScenery model = tsbll.GetModel(Convert.ToInt32(this.txtTsc_Name2.Tag));
- model.Tsc_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtTsc_Name2.Text.Trim());
- model.Tsc_Rating = ((ListItem)this.cmbTsc_Rating2.SelectedItem).StrValue.ToString().Trim();
- model.Tsc_IsDisable = this.cmbtreevIsDisable2.Tag.ToString().Trim();
- model.Tsc_Remark = txtTsc_Remark2.Text;
- if (cmbTcs_Category2.Text == "内景")
- { model.Tcs_Category = 0; }
- else
- { model.Tcs_Category = 1; }
- model.Tsc_UpdateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Tsc_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- if (!tsbll.Update(model))
- { MessageBoxCustom.Show("保存失败!"); return; }
- }
- this.GetAttractionsCs();
- this.BindClear2();
- MessageBoxCustom.Show("保存成功!");
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- #endregion
- }
- }
- }
|