]> insang Git - newton-cn_pos.git/commitdiff
일회용적립 끝
authornewton-cn <insang@kakao.com>
Sat, 11 Jan 2025 11:22:03 +0000 (20:22 +0900)
committernewton-cn <insang@kakao.com>
Sat, 11 Jan 2025 11:22:03 +0000 (20:22 +0900)
12 files changed:
.vs/newton-cn/v16/.suo
newton-cn/DBConnector.cs
newton-cn/Form1.cs
newton-cn/Form5.Designer.cs
newton-cn/Form5.cs
newton-cn/Form5.resx
newton-cn/bin/Debug/newton-cn.exe
newton-cn/bin/Debug/newton-cn.pdb
newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache
newton-cn/obj/Debug/newton-cn.csproj.GenerateResource.cache
newton-cn/obj/Debug/newton-cn.exe
newton-cn/obj/Debug/newton-cn.pdb

index d2a27b385c727c46ed9201b8d8f28c32e90a1848..06d46808a29d0450127ba050c1ee33b4a4be4d93 100644 (file)
Binary files a/.vs/newton-cn/v16/.suo and b/.vs/newton-cn/v16/.suo differ
index 5eb1f156d34c2fdf4513c080b57e35b3ac1fdfc1..a567b486545bbc3bb0ca59f7e93eff9c565b7c7a 100644 (file)
@@ -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<Dictionary<string, string>> getDisposableIsEarn(string selected)
+        {
+            List<Dictionary<string, string>> result = new List<Dictionary<string, string>>();
+#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<string, string> dict = new Dictionary<string, string>();
+                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<Dictionary<string, string>> getList(string item)
         {
             List<Dictionary<string, string>> result = new List<Dictionary<string, string>>();
index ee2a0caf5d20e233f07b5d87af9d2abfe6d0712d..4e8299840d322c1610593b1c78e5e2c097c288aa 100644 (file)
@@ -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();
index 0fbcb80422b8a7ee5b2ce508ae8ffb137199f427..21a971a9d9147e31816295c67b677f1f94a088da 100644 (file)
@@ -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
index 76ca66161930278361f7900fcc6e20b581aaf5a2..792c6280ee94481d333a0d3f6f8069cddad6ea13 100644 (file)
@@ -11,6 +11,8 @@ namespace newton_cn
 {
     public partial class Form5 : Form
     {
+        Dictionary<string, string> 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<Dictionary<string, string>> 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();
+            }
         }
     }
 }
index 7080a7d118e8cd7ec668e9bb0d8e90767e0c7a3c..a40568072d671e8ee4106e3b456f130be6ccacd9 100644 (file)
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="button3.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>
\ No newline at end of file
index acf3fac466934322ca990db58beee4c516308271..6229883aa305a64b158bd226deebc03344d71fae 100644 (file)
Binary files a/newton-cn/bin/Debug/newton-cn.exe and b/newton-cn/bin/Debug/newton-cn.exe differ
index 6f5b658f5cf29f7fe244737e186a19da3d9f0aac..2569670350dd6af20593014a37977b9973aee122 100644 (file)
Binary files a/newton-cn/bin/Debug/newton-cn.pdb and b/newton-cn/bin/Debug/newton-cn.pdb differ
index 328c5ac9bad0bbb82b826103e50179c57e0c0868..8c45cb42fd47b55612edf07c9e36ad965212d48d 100644 (file)
Binary files a/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ
index fa65fa58e3f5cc8753643e1b3f2a87bd969e30e0..0b3325a0627d9207340c90439346d4333385aad9 100644 (file)
Binary files a/newton-cn/obj/Debug/newton-cn.csproj.GenerateResource.cache and b/newton-cn/obj/Debug/newton-cn.csproj.GenerateResource.cache differ
index acf3fac466934322ca990db58beee4c516308271..6229883aa305a64b158bd226deebc03344d71fae 100644 (file)
Binary files a/newton-cn/obj/Debug/newton-cn.exe and b/newton-cn/obj/Debug/newton-cn.exe differ
index 6f5b658f5cf29f7fe244737e186a19da3d9f0aac..2569670350dd6af20593014a37977b9973aee122 100644 (file)
Binary files a/newton-cn/obj/Debug/newton-cn.pdb and b/newton-cn/obj/Debug/newton-cn.pdb differ