From 84616e6d524a7df88ebcca4b74aca42461f34605 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 19 六月 2020 20:25:09 +0800 Subject: [PATCH] '商品信息完善' --- WindowsFormsApp1/Main.cs | 303 +++++++++++++++++++++++++++++++++++--------------- 1 files changed, 210 insertions(+), 93 deletions(-) diff --git a/WindowsFormsApp1/Main.cs b/WindowsFormsApp1/Main.cs index 140680f..2a8d046 100644 --- a/WindowsFormsApp1/Main.cs +++ b/WindowsFormsApp1/Main.cs @@ -14,6 +14,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using WindowsFormsApp1.entity; +using WindowsFormsApp1.entity.tb; using WindowsFormsApp1.utils; using WindowsFormsApp1.utils.tb; using WindowsFormsApp1.utils.ui; @@ -27,8 +28,10 @@ InitializeComponent(); InitSkin(); InitDataGridView(); + InitLogListView(); InitData(); initTextBox(); + ShowLog(); } @@ -43,7 +46,97 @@ this.sdljGoodsTimer.Interval = 1000*60*5; this.sdljGoodsTimer.Start(); this.tabControl1.SendToBack(); - this.label11.BringToFront(); + + //鍒濆鍖栬处鎴风櫥褰曪紝娣樺疂鐧诲綍 + UserInfo user= LoginManager.GetLoginUser(); + if (user != null) {//鑷姩鐧诲綍 + LoginManager.LoginSuccess(user); + //璁剧疆鐧诲綍鐘舵�� + setUserInfo(user); + } + + //鍒濆鍖栨窐瀹濈櫥褰� + List<TBAccountLogin> accountList= TBAccountManager.GetAccountList(); + if (accountList != null) { + foreach (TBAccountLogin account in accountList) { + account.Login = false; + if (!Constant.tbAccountMap.ContainsKey(account.Index))//鍘婚噸 + Constant.tbAccountMap.Add( account.Index,account); + } + } + //寮�鍚棩蹇楁樉绀� + this.logTimer.Start(); + //鑾峰彇閰嶇疆鍙傛暟 + ApiUtil.GetConfig((String result) => + { + JObject obj= JObject.Parse(result); + if (Convert.ToInt32(obj["code"]) == 0) { + + List<Config> configList= JsonConvert.DeserializeObject <List<Config>>(obj["data"].ToString()); + if (configList != null) + foreach (Config cf in configList) { + SQLiteDataBaseUtil.getInstance().AddConfig(cf); + } + } + + }); + } + + //楠岃瘉鐧诲綍 + private bool IsLogin() { + if (LoginManager.GetLoginUser() != null) + return true; + MessageBox.Show("璇风櫥褰�"); + return false; + } + + + //鍒濆鍖杔istview + private void InitLogListView() { + this.listView1.GridLines = false; + this.listView1.View = View.Details; + this.listView1.HeaderStyle = ColumnHeaderStyle.None; + ColumnHeader ch = new ColumnHeader(); + ch.Text = ""; //璁剧疆鍒楁爣棰� + ch.Width = 0; //璁剧疆鍒楀搴� + ch.TextAlign = HorizontalAlignment.Left; //璁剧疆鍒楃殑瀵归綈鏂瑰紡 + this.listView1.Columns.Add(ch); + ch = new ColumnHeader(); + ch.Text = ""; //璁剧疆鍒楁爣棰� + ch.Width = 120; //璁剧疆鍒楀搴� + ch.TextAlign = HorizontalAlignment.Left; //璁剧疆鍒楃殑瀵归綈鏂瑰紡 + this.listView1.Columns.Add(ch); + + ch = new ColumnHeader(); + ch.Text = ""; //璁剧疆鍒楁爣棰� + ch.Width = 300; //璁剧疆鍒楀搴� + ch.TextAlign = HorizontalAlignment.Left; //璁剧疆鍒楃殑瀵归綈鏂瑰紡 + this.listView1.Columns.Add(ch); + } + + //鏄剧ず鏃ュ織 + private void ShowLog() { + List <LogInfo> logList= LogManager.GetLogList(); + if (this.listView1.Items.Count >= logList.Count) + return; + this.listView1.BeginUpdate(); + + for (int i = this.listView1.Items.Count; i < logList.Count; i++) { + LogInfo log = logList[i]; + ListViewItem lvi = new ListViewItem(); + lvi.Font = new Font("寰蒋闆呴粦", 9, FontStyle.Regular); + lvi.SubItems.Add(TimeUtil.GetGeneralTime(log.Time, "yyyy-MM-dd HH:mm")); + lvi.SubItems.Add(log.Content); + if (log.Type == LogInfo.TYPE_DENGER) + lvi.ForeColor = Color.Red; + else if (log.Type == LogInfo.TYPE_SAFE) + lvi.ForeColor = Color.Green; + else if (log.Type == LogInfo.TYPE_NORMAL) + lvi.ForeColor = Color.Gray; + this.listView1.Items.Add(lvi); + } + this.listView1.Items[this.listView1.Items.Count - 1].EnsureVisible(); + this.listView1.EndUpdate(); } @@ -54,18 +147,7 @@ } private void initTextBox() { - setTextBoxPrompt(this.textBox1,"鏈�灏忓��"); - setTextBoxPrompt(this.textBox2, "鏈�澶у��"); - setTextBoxPrompt(this.textBox3, "鏈�灏忓��"); - setTextBoxPrompt(this.textBox4, "鏈�澶у��"); - setTextBoxPrompt(this.textBox5, "鏈�灏忓��"); - setTextBoxPrompt(this.textBox6, "鏈�澶у��"); - setTextBoxPrompt(this.textBox7, "鏈�灏忓��"); - setTextBoxPrompt(this.textBox8, "鏈�澶у��"); - setTextBoxPrompt(this.textBox9, "鏈�灏忓��"); - setTextBoxPrompt(this.textBox10, "鏈�澶у��"); - setTextBoxPrompt(this.textBox11, "鏈�灏忓��"); - setTextBoxPrompt(this.textBox12, "鏈�澶у��"); + } /** @@ -100,18 +182,12 @@ SetGoodsData((bool) hasMore, goodsList); } - private void searchSuccess(String result) - { - JObject obj = JObject.Parse(result); - this.BeginInvoke(new SetGoodsAndClassDataDelegate(setGoodsAndClassData), obj); - } - private void search(int page, SearchInfo info) { - - OnSuccess onSuccess = searchSuccess; - - ApiUtil.searchGoods( classType, info, page, onSuccess); + ApiUtil.searchGoods( classType, info, page, new OnSuccess((String result)=> { + JObject obj = JObject.Parse(result); + this.BeginInvoke(new SetGoodsAndClassDataDelegate(setGoodsAndClassData), obj); + })); } int page = 1; @@ -122,16 +198,19 @@ this.dataGridView1.Rows.Clear(); foreach (FirstOrderSubInfo info in infoList) { int index = this.dataGridView1.Rows.Add(); - this.dataGridView1.Rows[index].Cells[0].Value = info.Index; + //this.dataGridView1.Rows[index].Cells[0].Value = info.GoodsId; this.dataGridView1.Rows[index].Cells[1].Value = info.Title; - this.dataGridView1.Rows[index].Cells[2].Value = info.ZkPrice; - this.dataGridView1.Rows[index].Cells[3].Value = info.CouponPrice; - this.dataGridView1.Rows[index].Cells[4].Value = info.LijinAmount; - this.dataGridView1.Rows[index].Cells[5].Value = info.ActualPrice; - this.dataGridView1.Rows[index].Cells[6].Value = info.Commission; - this.dataGridView1.Rows[index].Cells[7].Value = info.CommissionRate; - this.dataGridView1.Rows[index].Cells[8].Value = "鍔犲叆寮曞崟搴�"; - this.dataGridView1.Rows[index].Cells[9].Value = "鍔犲叆瀹炴媿搴�"; + this.dataGridView1.Rows[index].Cells[2].Value = info.SalesNum; + this.dataGridView1.Rows[index].Cells[3].Value = info.ZkPrice; + this.dataGridView1.Rows[index].Cells[4].Value = info.CouponAmount; + this.dataGridView1.Rows[index].Cells[5].Value = info.CouponPrice; + this.dataGridView1.Rows[index].Cells[6].Value = info.LijinAmount; + this.dataGridView1.Rows[index].Cells[7].Value = info.ActualPrice; + this.dataGridView1.Rows[index].Cells[8].Value = info.Commission; + this.dataGridView1.Rows[index].Cells[9].Value = info.CommissionRate; + this.dataGridView1.Rows[index].Cells[10].Value = info.Tmall == 1 ? "澶╃尗" : "娣樺疂"; + if(info.Mark) + this.dataGridView1.Rows[index].DefaultCellStyle.BackColor = Color.Red; } if (hasMore) @@ -164,6 +243,15 @@ this.dataGridView1.Columns[7].Width = 65; this.dataGridView1.Columns[8].Width = 75; this.dataGridView1.Columns[9].Width = 75; + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Menu; + dataGridViewCellStyle1.Font = new System.Drawing.Font("寰蒋闆呴粦", 9F); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; } @@ -195,54 +283,38 @@ } Console.WriteLine("鍒嗙被:" + item.DataSource.Key); page = 1; - SearchInfo searchInfo = getSearchFilter(); + SearchInfo searchInfo =this.kssdljSearchPannel1.getSearchFilter(); classType = Convert.ToInt32(item.DataSource.Key); searchInfo.Key = this.ucTextBoxEx1.InputText; search(page, searchInfo); } - - private SearchInfo getSearchFilter() - { - SearchInfo info = new SearchInfo(); - info.MinCouponPrice = this.textBox1.Text; - info.MaxCouponPrice = this.textBox2.Text; - - info.MinLiJin = this.textBox3.Text; - info.MaxLiJin = this.textBox4.Text; - - info.MinActualPrice = this.textBox5.Text; - info.MaxActualPrice = this.textBox6.Text; - - info.MinSalesNum = this.textBox7.Text; - info.MinSalesNum = this.textBox8.Text; - - info.MinCommission = this.textBox9.Text; - info.MaxCommission = this.textBox10.Text; - - info.MinCommissionRate = this.textBox11.Text; - info.MaxCommissionRate = this.textBox12.Text; - - return info; - } - //绛涢�� private void button1_Click_1(object sender, EventArgs e) { - page = 1; - SearchInfo searchInfo = getSearchFilter(); - classType = 0; - search(page, searchInfo); - Console.WriteLine(JsonConvert.SerializeObject(searchInfo)); + if (!IsLogin()) + return; + + InputDialog input = new InputDialog("搴旂敤绛涢�夊懡鍚�", "搴旂敤绛涢�夋槸鑷姩鐢熸垚鏂囨浜戝彂鍗曞繀瑕佽缃�", new OnSuccess((String result)=> { + + //TODO 鎻掑叆寮曞崟缁勫悎 + FormUtil.ShowDialog(new YingDanSelect()); + + + })); + + FormUtil.ShowDialog(input); } //鎼滅储 private void button5_Click_2(object sender, EventArgs e) { + if (!IsLogin()) + return; classType = 0; page = 1; - SearchInfo searchInfo = getSearchFilter(); + SearchInfo searchInfo = this.kssdljSearchPannel1.getSearchFilter(); searchInfo.Key = this.ucTextBoxEx1.InputText; search(page, searchInfo); } @@ -251,8 +323,10 @@ //涓嬩竴椤� private void next_Click(object sender, EventArgs e) { + if (!IsLogin()) + return; page++; - SearchInfo searchInfo = getSearchFilter(); + SearchInfo searchInfo = this.kssdljSearchPannel1.getSearchFilter(); searchInfo.Key = this.ucTextBoxEx1.InputText; search(page, searchInfo); } @@ -260,8 +334,10 @@ //涓婁竴椤� private void before_Click(object sender, EventArgs e) { + if (!IsLogin()) + return; page--; - SearchInfo searchInfo = getSearchFilter(); + SearchInfo searchInfo = this.kssdljSearchPannel1.getSearchFilter(); searchInfo.Key = this.ucTextBoxEx1.InputText; search(page, searchInfo); } @@ -335,20 +411,31 @@ //璁剧疆鐢ㄦ埛淇℃伅 private void setUserInfo(UserInfo user) { - this.label37.Visible = true; - if (user.SdljShareExpireTime == null || DateTime.Now > user.SdljShareExpireTime) - { //杩囨湡 - this.button8.Text = "鍗囩骇鍏变韩"; + if (user != null) + { + + this.label37.Visible = true; + if (user.SdljShareExpireTime == null) + { //杩囨湡 + this.button8.Text = "鍗囩骇鍏变韩"; + this.button8.Click -= new System.EventHandler(this.login_Click); + this.button8.Click += new System.EventHandler(this.upgrade_Click);//鍗囩骇 + } + else + { + this.button8.Text = "鍏变韩缁湡"; + this.button8.Click -= new System.EventHandler(this.login_Click); + this.button8.Click += new System.EventHandler(this.upgrade_Click);//鍗囩骇 + } + this.label37.Visible = true; this.button8.Click -= new System.EventHandler(this.login_Click); - this.button8.Click += new System.EventHandler(this.upgrade_Click);//鍗囩骇 } else { - + this.label37.Visible = false; + this.button8.Text = "鐧诲綍"; + this.button8.Click += new System.EventHandler(this.login_Click); + this.button8.Click -= new System.EventHandler(this.upgrade_Click);//鍗囩骇 } - - this.button8.Text = "鍗囩骇鍏变韩"; - this.label37.Visible = true; - this.button8.Click -= new System.EventHandler(this.login_Click); } @@ -361,26 +448,33 @@ setUserInfo(user); - })); + }),user); }); FormUtil.ShowDialog(loginNew); - } private void upgrade_Click(object sender, EventArgs e) { - LoginNew loginNew = new LoginNew((UserInfo user) => { //鐧诲綍鎴愬姛 - //UI绾跨▼ - this.BeginInvoke(new LoginSuccessDelegate((UserInfo user1) => { //鐧诲綍 - - setUserInfo(user); - - })); - + ApiUtil.GetUserInfo((String result) => + { + JObject obj= JObject.Parse(result); + if (Convert.ToInt32(obj["code"]) == 0) + { + UserInfo user= JsonConvert.DeserializeObject<UserInfo>(obj["data"].ToString()); + //鍒版湡鏃堕棿 + this.BeginInvoke(new LoginSuccessDelegate((UserInfo user1)=> { + CardPwd cardPwd = new CardPwd(user1.SdljShareExpireTime); + FormUtil.ShowDialog(cardPwd); + }), user); + } + else { + MessageBox.Show(obj["msg"].ToString()); + } }); - FormUtil.ShowDialog(loginNew); + + } private void button5_Click(object sender, EventArgs e) @@ -448,11 +542,6 @@ } - private void checkBox7_CheckedChanged(object sender, EventArgs e) - { - - } - private void checkBox1_CheckedChanged(object sender, EventArgs e) { @@ -483,13 +572,16 @@ //鎺ㄥ箍杞欢 private void promotion_Click(object sender, EventArgs e) { + if (!IsLogin()) + return; Promotion pt = new Promotion(); FormUtil.ShowDialog(pt); } //寰俊缇� private void wxGroup_Click(object sender, EventArgs e) { - WXGroup pt = new WXGroup(); + Config config = SQLiteDataBaseUtil.getInstance().GetConfig("xianbao_group_picture"); + WXGroup pt = new WXGroup("鎵爜杩涚兢", config!=null?config.Value:""); FormUtil.ShowDialog(pt); } @@ -497,6 +589,8 @@ //鍙戝崟鏈哄櫒浜� private void fadanRobot_Click(object sender, EventArgs e) { + if (!IsLogin()) + return; FaDanRobot pt = new FaDanRobot(); FormUtil.ShowDialog(pt); } @@ -504,11 +598,15 @@ //娣樺疂鎺堟潈 private void tbAuth_Click(object sender, EventArgs e) { + if (!IsLogin()) + return; TBAuth login = new TBAuth(); FormUtil.ShowDialog(login); } //鍙戝崟搴� private void fadanKu_Click(object sender, EventArgs e) { + if (!IsLogin()) + return; FaDanKu login = new FaDanKu(); FormUtil.ShowDialog(login); } @@ -560,6 +658,8 @@ //鎺堟潈鐧诲綍 private void button10_Click(object sender, EventArgs e) { + if (!IsLogin()) + return; Login login = new Login(); FormUtil.ShowDialog(login); } @@ -579,5 +679,22 @@ { e.Graphics.Clear(this.BackColor); } + + private void logTimer_Tick(object sender, EventArgs e) + { + ShowLog(); + } + + private void Main_FormClosed(object sender, FormClosedEventArgs e) + { + this.logTimer.Stop(); + } + + //閫�鍑虹櫥褰� + private void label37_Click(object sender, EventArgs e) + { + LoginManager.ExitLogin(); + setUserInfo(null); + } } } -- Gitblit v1.8.0