From: newton-cn Date: Sat, 11 Jan 2025 11:22:03 +0000 (+0900) Subject: 일회용적립 끝 X-Git-Url: https://git.insang.kr/gitweb/?a=commitdiff_plain;h=55a49b54e258ad17d6c868dee3f64aa8b394c2dc;p=newton-cn_pos.git 일회용적립 끝 --- diff --git a/.vs/newton-cn/v16/.suo b/.vs/newton-cn/v16/.suo index d2a27b3..06d4680 100644 Binary files a/.vs/newton-cn/v16/.suo and b/.vs/newton-cn/v16/.suo differ diff --git a/newton-cn/DBConnector.cs b/newton-cn/DBConnector.cs index 5eb1f15..a567b48 100644 --- a/newton-cn/DBConnector.cs +++ b/newton-cn/DBConnector.cs @@ -10,6 +10,142 @@ namespace newton_cn { class DBConnector { + public int updateDisposableIsEarn_log(string pe_id, string ps_no) + { +#if DEBUG + SqlConnection conn = new SqlConnection("Data Source=newton-cn1.iptime.org, 1818; Initial Catalog=food; User ID=newton; Password=newton123!;"); +#else + SqlConnection conn = new SqlConnection("Data Source=localhost; Initial Catalog=food; User ID=newton; Password=newton123!;"); +#endif + conn.Open(); + + string sql = ""; + sql += @" + insert into disposable_earn_point_status (pe_id, ps_no, is_earn) values('" + pe_id + @"', '" + ps_no + @"', 1) + "; + + SqlCommand cmd_select = new SqlCommand(sql, conn); + + int result = cmd_select.ExecuteNonQuery(); + + return result; + } + public int updateDisposableIsEarn(string ct_code, double addpoint) + { +#if DEBUG + SqlConnection conn = new SqlConnection("Data Source=newton-cn1.iptime.org, 1818; Initial Catalog=food; User ID=newton; Password=newton123!;"); +#else + SqlConnection conn = new SqlConnection("Data Source=localhost; Initial Catalog=food; User ID=newton; Password=newton123!;"); +#endif + conn.Open(); + + string sql = ""; + sql += @" + update ct set ct_tpoint= ct_tpoint + " + addpoint + @", ct_rpoint= ct_rpoint + " + addpoint + @" where ct_code= '" + ct_code + @"' + "; + + SqlCommand cmd_select = new SqlCommand(sql, conn); + + int result = cmd_select.ExecuteNonQuery(); + + return result; + } + public List> getDisposableIsEarn(string selected) + { + List> result = new List>(); +#if DEBUG + SqlConnection conn = new SqlConnection("Data Source=newton-cn1.iptime.org, 1818; Initial Catalog=food; User ID=newton; Password=newton123!;"); +#else + SqlConnection conn = new SqlConnection("Data Source=localhost; Initial Catalog=food; User ID=newton; Password=newton123!;"); +#endif + + conn.Open(); + + string sql = ""; + sql += @" + select + CONVERT(CHAR(19), a1.ps_date, 20) as ps_date, a2.ct_code, a2.ct_name, a1.ps_prname, cast(a1.ps_qty as int) ps_qty, + cast( + a1.ps_up + + + case when ( + isnull( + ( + isnull((select sum(ps_up * ps_qty) from ps where pe_id= a1.pe_id and ps_prcode not in (select pr_code from pr where kind_code= '1100') and ps_prcode not in (select pr_code from pr where kind_code= '1099')), 0) + + + ( + select + sum(ps_up * ps_qty)/(select count(pe_id) from ps where pe_id= a1.pe_id and ps_prcode not in (select pr_code from pr where kind_code= '1100') and ps_prcode in (select pr_code from pr where kind_code= '1099')) + from + ps + where + ps_prcode in (select pr_code from pr where kind_code= '1100') and pe_id= a1.pe_id + ) + ) + , 0) + ) < 0 then + isnull( + ( + isnull((select sum(ps_up * ps_qty) from ps where pe_id= a1.pe_id and ps_prcode not in (select pr_code from pr where kind_code= '1100') and ps_prcode not in (select pr_code from pr where kind_code= '1099')), 0) + + + ( + select + sum(ps_up * ps_qty)/(select count(pe_id) from ps where pe_id= a1.pe_id and ps_prcode not in (select pr_code from pr where kind_code= '1100') and ps_prcode in (select pr_code from pr where kind_code= '1099')) + from + ps + where + ps_prcode in (select pr_code from pr where kind_code= '1100') and pe_id= a1.pe_id + ) + ) + , 0) else + 0 end + as int) as pe_bamt, + a1.pe_id, a1.ps_no, isnull(a3.is_earn, 0) as is_earn + from + ps a1 + join pe a2 + on a1.pe_id= a2.pe_id and a2.ct_code != '' + left join disposable_earn_point_status a3 + on a3.pe_id= a1.pe_id and a3.ps_no= a1.ps_no + join ac a4 + on a4.pe_id= a1.pe_id and a4.ac_fncd2 not in ('01', '00') + where + a1.ps_prcode in ( + select pr_code from pr where kind_code= '1099' + ) + and a1.ps_date between '" + selected + @"' and dateadd(day, 1, '" + selected + @"') + order by + a1.pe_id desc; + + create table disposable_earn_point_status( + pe_id varchar, + ps_no varchar, + is_earn bit default 0, + udate datetime default getdate() + ); + "; + + SqlCommand cmd_select = new SqlCommand(sql, conn); + + SqlDataReader rd = cmd_select.ExecuteReader(); + + while (rd.Read()) + { + Dictionary dict = new Dictionary(); + dict["ps_date"] = rd["ps_date"].ToString(); + dict["ct_code"] = rd["ct_code"].ToString(); + dict["ct_name"] = rd["ct_name"].ToString(); + dict["ps_prname"] = rd["ps_prname"].ToString(); + dict["ps_qty"] = rd["ps_qty"].ToString(); + dict["pe_bamt"] = rd["pe_bamt"].ToString(); + dict["pe_id"] = rd["pe_id"].ToString(); + dict["ps_no"] = rd["ps_no"].ToString(); + dict["is_earn"] = rd["is_earn"].ToString(); + result.Add(dict); + } + + return result; + } public List> getList(string item) { List> result = new List>(); diff --git a/newton-cn/Form1.cs b/newton-cn/Form1.cs index ee2a0ca..4e82998 100644 --- a/newton-cn/Form1.cs +++ b/newton-cn/Form1.cs @@ -69,7 +69,7 @@ namespace newton_cn private void button4_Click(object sender, EventArgs e) { - Console.WriteLine("폼띄우기"); + //Console.WriteLine("폼띄우기"); Form5 dlg = new Form5(); dlg.ShowDialog(); diff --git a/newton-cn/Form5.Designer.cs b/newton-cn/Form5.Designer.cs index 0fbcb80..21a971a 100644 --- a/newton-cn/Form5.Designer.cs +++ b/newton-cn/Form5.Designer.cs @@ -34,11 +34,13 @@ namespace newton_cn this.label1 = new System.Windows.Forms.Label(); this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); this.button2 = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.button3 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // - this.button1.Location = new System.Drawing.Point(757, 12); + this.button1.Location = new System.Drawing.Point(606, 11); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(31, 27); this.button1.TabIndex = 0; @@ -48,19 +50,22 @@ namespace newton_cn // // listView1 // + this.listView1.Font = new System.Drawing.Font("굴림", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); this.listView1.HideSelection = false; - this.listView1.Location = new System.Drawing.Point(12, 45); + this.listView1.Location = new System.Drawing.Point(12, 85); this.listView1.Name = "listView1"; - this.listView1.Size = new System.Drawing.Size(776, 307); + this.listView1.Size = new System.Drawing.Size(625, 267); this.listView1.TabIndex = 1; this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(81, 18); + this.label1.Font = new System.Drawing.Font("굴림", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label1.Location = new System.Drawing.Point(80, 14); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(105, 12); + this.label1.Size = new System.Drawing.Size(150, 16); this.label1.TabIndex = 2; this.label1.Text = "일회용 포인트적립"; // @@ -70,25 +75,49 @@ namespace newton_cn this.dateTimePicker1.Font = new System.Drawing.Font("굴림", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); this.dateTimePicker1.Location = new System.Drawing.Point(319, 8); this.dateTimePicker1.Name = "dateTimePicker1"; - this.dateTimePicker1.Size = new System.Drawing.Size(131, 26); + this.dateTimePicker1.Size = new System.Drawing.Size(140, 26); this.dateTimePicker1.TabIndex = 3; this.dateTimePicker1.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged); // // button2 // - this.button2.Location = new System.Drawing.Point(713, 395); + this.button2.Location = new System.Drawing.Point(532, 358); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.Size = new System.Drawing.Size(105, 39); this.button2.TabIndex = 4; this.button2.Text = "5% 적립"; this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label2.ForeColor = System.Drawing.Color.Red; + this.label2.Location = new System.Drawing.Point(36, 51); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(571, 21); + this.label2.TabIndex = 5; + this.label2.Text = "# 이 화면은 회원 결제건중 일회용 현금구매 내역만 나옴"; + // + // button3 + // + this.button3.Location = new System.Drawing.Point(285, 358); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(165, 39); + this.button3.TabIndex = 6; + this.button3.Text = "이미 수기로 적립하였음"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); // // Form5 // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(650, 402); this.ControlBox = false; + this.Controls.Add(this.button3); + this.Controls.Add(this.label2); this.Controls.Add(this.button2); this.Controls.Add(this.dateTimePicker1); this.Controls.Add(this.label1); @@ -110,5 +139,7 @@ namespace newton_cn private System.Windows.Forms.Label label1; private System.Windows.Forms.DateTimePicker dateTimePicker1; private System.Windows.Forms.Button button2; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button3; } } \ No newline at end of file diff --git a/newton-cn/Form5.cs b/newton-cn/Form5.cs index 76ca661..792c628 100644 --- a/newton-cn/Form5.cs +++ b/newton-cn/Form5.cs @@ -11,6 +11,8 @@ namespace newton_cn { public partial class Form5 : Form { + Dictionary updateList; + public Form5() { InitializeComponent(); @@ -18,9 +20,25 @@ namespace newton_cn dateTimePicker1.CustomFormat = "yyyy-MM-dd"; } + private void Form5_Load(object sender, EventArgs e) { + //ListViewItem_SetSpacing(this.listView1, 500 + 100, 500 + 200); + listView1.View = View.Details; + listView1.GridLines = true; + listView1.FullRowSelect = true; + listView1.Columns.Add("구매일시", 160); + listView1.Columns.Add("회원명", 70); + listView1.Columns.Add("상품명", 170); + listView1.Columns.Add("갯수", 50); + listView1.Columns.Add("적립대상금액", 100); + listView1.Columns.Add("적립여부", 70); + listView1.Columns.Add("pe_id", 70); + listView1.Columns.Add("ps_no", 70); + listView1.Columns.Add("ct_code", 70); + + Console.WriteLine(dateTimePicker1.Text); } private void button1_Click(object sender, EventArgs e) @@ -30,7 +48,160 @@ namespace newton_cn private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { + Console.WriteLine(dateTimePicker1.Text); + listView1.Items.Clear(); + string selected = dateTimePicker1.Text; + DBConnector dbc = new DBConnector(); + List> list = dbc.getDisposableIsEarn(selected); + + for (int i = 0; i < list.Count; i++) + { + String[] item = + { + list[i]["ps_date"], + list[i]["ct_name"], + list[i]["ps_prname"], + list[i]["ps_qty"], + list[i]["pe_bamt"], + Convert.ToBoolean(list[i]["is_earn"]) ? "O" : "X", + list[i]["pe_id"], + list[i]["ps_no"], + list[i]["ct_code"], + }; + ListViewItem lvi = new ListViewItem(item); + listView1.Items.Add(lvi); + } + } + + private void listView1_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void button2_Click(object sender, EventArgs e) + { + ListView.SelectedListViewItemCollection selected = listView1.SelectedItems; + double earnPercent = 0.05; + string ct_code = ""; + int point = 0; + string pe_id = ""; + string ps_no = ""; + int is_earn = 0; + foreach (ListViewItem item in selected) + { + + for (int i = 0; i < listView1.Columns.Count; i++) + { + if (i == 3) + { + point = Convert.ToInt32(item.SubItems[i].Text); + } + else if (i == 4) + { + point = point * Convert.ToInt32(item.SubItems[i].Text); + } + else if (i == 5) + { + is_earn = item.SubItems[i].Text == "X" ? 0 : 1; + } + else if (i == 6) + { + pe_id = item.SubItems[i].Text; + } + else if (i == 7) + { + ps_no = item.SubItems[i].Text; + } + else if (i == 8) + { + ct_code = item.SubItems[i].Text; + } + } + } + + if (ct_code == "" && point == 0) + { + MessageBox.Show("설정 할 목록이 선택되지 않았습니다."); + return; + } + + double addPoint = point * earnPercent; + + if (is_earn == 1) + { + MessageBox.Show(new Form { TopMost = true }, "이미 적립처리 된 내역입니다."); + return; + } + + DBConnector dbc = new DBConnector(); + int result = dbc.updateDisposableIsEarn(ct_code, addPoint); + + if (result == 1) + { + result = dbc.updateDisposableIsEarn_log(pe_id, ps_no); + } + + if (result == 1) + { + MessageBox.Show(new Form { TopMost = true }, "포인트적립완료!"); + Application.OpenForms["Form5"].Close(); + } + } + + private void button3_Click(object sender, EventArgs e) + { + ListView.SelectedListViewItemCollection selected = listView1.SelectedItems; + string pe_id = ""; + string ps_no = ""; + int is_earn = 0; + + foreach (ListViewItem item in selected) + { + + for (int i = 0; i < listView1.Columns.Count; i++) + { + + if (i == 5) + { + is_earn = item.SubItems[i].Text == "X" ? 0 : 1; + } + else if (i == 6) + { + pe_id = item.SubItems[i].Text; + } + else if (i == 7) + { + ps_no = item.SubItems[i].Text; + } + + } + } + + if (pe_id == "" && ps_no == "") + { + MessageBox.Show("설정 할 목록이 선택되지 않았습니다."); + return; + } + + DBConnector dbc = new DBConnector(); + int result; + + if (is_earn == 1) + { + MessageBox.Show(new Form { TopMost = true }, "이미 적립처리 된 내역입니다."); + return; + } + else + { + result = dbc.updateDisposableIsEarn_log(pe_id, ps_no); + } + + if (result == 1) + { + MessageBox.Show(new Form { TopMost = true }, "적용완료!"); + Application.OpenForms["Form5"].Close(); + } } } } diff --git a/newton-cn/Form5.resx b/newton-cn/Form5.resx index 7080a7d..a405680 100644 --- a/newton-cn/Form5.resx +++ b/newton-cn/Form5.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + \ No newline at end of file diff --git a/newton-cn/bin/Debug/newton-cn.exe b/newton-cn/bin/Debug/newton-cn.exe index acf3fac..6229883 100644 Binary files a/newton-cn/bin/Debug/newton-cn.exe and b/newton-cn/bin/Debug/newton-cn.exe differ diff --git a/newton-cn/bin/Debug/newton-cn.pdb b/newton-cn/bin/Debug/newton-cn.pdb index 6f5b658..2569670 100644 Binary files a/newton-cn/bin/Debug/newton-cn.pdb and b/newton-cn/bin/Debug/newton-cn.pdb differ diff --git a/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 328c5ac..8c45cb4 100644 Binary files a/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/newton-cn/obj/Debug/newton-cn.csproj.GenerateResource.cache b/newton-cn/obj/Debug/newton-cn.csproj.GenerateResource.cache index fa65fa5..0b3325a 100644 Binary files a/newton-cn/obj/Debug/newton-cn.csproj.GenerateResource.cache and b/newton-cn/obj/Debug/newton-cn.csproj.GenerateResource.cache differ diff --git a/newton-cn/obj/Debug/newton-cn.exe b/newton-cn/obj/Debug/newton-cn.exe index acf3fac..6229883 100644 Binary files a/newton-cn/obj/Debug/newton-cn.exe and b/newton-cn/obj/Debug/newton-cn.exe differ diff --git a/newton-cn/obj/Debug/newton-cn.pdb b/newton-cn/obj/Debug/newton-cn.pdb index 6f5b658..2569670 100644 Binary files a/newton-cn/obj/Debug/newton-cn.pdb and b/newton-cn/obj/Debug/newton-cn.pdb differ