示例#1
0
文件: Login.cs 项目: CU-PBL/cu-client
        private void button1_Click(object sender, EventArgs e)
        {
            var userData = new UserData {
                id = textBox1.Text, passwd = textBox2.Text
            };

            var result = Cson <UserData> .Parse(userData);

            var client  = new RestClient(ConstantData.SERVER + "/login");
            var request = new RestRequest(Method.POST);

            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", result, ParameterType.RequestBody);
            var response = client.Execute(request);

            var loginResult = Cson <LoginData> .DeParse(response.Content);

//            Console.WriteLine($"로그인 결과: {loginResult.flag}");

            if (loginResult != null && loginResult.flag)
            {
                this.Hide();
                CU_Main main = new CU_Main();
                main.Show();
            }
            else
            {
                MessageBox.Show("로그인 정보가 일치하지 않습니다.", "사용자 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Text = "";
                textBox2.Text = "";
            }
        }
示例#2
0
文件: Sale.cs 项目: CU-PBL/cu-client
        private void button2_Click(object sender, EventArgs e)
        {
            int sum  = 0;
            var text = int.Parse(textBox1.Text);

            int[] data = new int[100];
            if (text < 1 || text > 100)
            {
                MessageBox.Show("없는 제품 번호");
            }
            else
            {
                data[text - 1] += 1;

                for (int i = 0; i < 100; i++)
                {
                    if (data[i] != 0)
                    {
                        var client   = new RestClient("http://106.10.42.112:8000/product/" + (i + 1));
                        var request  = new RestRequest(Method.GET);
                        var response = client.Execute(request);
                        var result   = Cson <ProductData> .DeParse(response.Content);

                        int setting = 0;
                        int set     = 0;
                        for (int j = 0; j < dataGridView1.Rows.Count; j++)
                        {
                            if ((int)dataGridView1.Rows[j].Cells["Column1"].Value == result.id)
                            {
                                setting = 1;
                                set     = j;
                            }
                        }

                        if (setting == 1)
                        {
                            int g = (int)dataGridView1.Rows[set].Cells["Column4"].Value;
                            dataGridView1.Rows[set].Cells["Column4"].Value = g + 1;
                            dataGridView1.Rows[set].Cells["Column5"].Value = result.price * (g + 1);
                        }
                        else
                        {
                            var index = dataGridView1.Rows.Add();
                            dataGridView1.Rows[index].Cells["Column1"].Value = result.id;
                            dataGridView1.Rows[index].Cells["Column2"].Value = result.name;
                            dataGridView1.Rows[index].Cells["Column3"].Value = result.price;
                            dataGridView1.Rows[index].Cells["Column4"].Value = 1;
                            dataGridView1.Rows[index].Cells["Column5"].Value = result.price;
                        }
                    }
                }
            }

            for (int j = 0; j < dataGridView1.Rows.Count; j++)
            {
                sum += (int)dataGridView1.Rows[j].Cells["Column5"].Value;
            }

            textBox3.Text = "" + sum;
        }
示例#3
0
        // 물품 리스트 보기
        static void CallPuductList()
        {
            var client   = new RestClient($"http://106.10.42.112:8000/product/list");
            var request  = new RestRequest(Method.GET);
            var response = client.Execute(request);

            var productList = Cson <Product> .ArrParse(response.Content);
        }
示例#4
0
文件: Stock.cs 项目: CU-PBL/cu-client
        public Stock()
        {
            InitializeComponent();
            Console.WriteLine("요청 보내는중...");
            var client   = new RestClient($"http://106.10.42.112:8000/stock/list");
            var request  = new RestRequest(Method.GET);
            var response = client.Execute(request);

            var productList = Cson <StockData> .ArrParse(response.Content);

            var cnt = 0;

            productList.ForEach(product =>
            {
                SaleView.Rows.Add();
                Console.WriteLine(product.id + product.name);
                SaleView.Rows[cnt].Cells["Column1"].Value = product.id;
                SaleView.Rows[cnt].Cells["Column2"].Value = product.name;
                SaleView.Rows[cnt].Cells["Column3"].Value = product.price;
                SaleView.Rows[cnt].Cells["Column4"].Value = product.stock;

                ++cnt;
            });
        }