ImportData_Interface Form

ImportData_Interface Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using db_models;
using ServiceSide;

namespace DKS
{
    public partial class ImportData_Interface : Form
    {
        public ImportData_Interface()
        {
            InitializeComponent();
        }

        ServiceSide.ServiceSide service = new ServiceSide.ServiceSide();

        /// <summary>
        /// 页面加载成功
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainInterface_Load(object sender, EventArgs e)
        {
            Yh yh = Single_Yh.GetYh();

            scy_name.Text = "司秤员:" + yh.name;
            time.Text = "时间:" + DateTime.Now.ToString("yyyy年MM月dd日 HH时mm分");

            var res = service.GetBF();
            if (res.code==200)
            {
                bf.DataSource = res.data;
                bf.DisplayMember = "bfms";
                bf.ValueMember = "bfbh";
                bf.Text = "";
            }
            else
            {
                MessageBox.Show(res.message);
            }

            var res2 = service.GetPm();
            if (res2.code==200)
            {
                pm.DataSource = res2.data;
                pm.DisplayMember = "pmms";
                pm.ValueMember = "pmbh";
                pm.Text = "";
            }
            else
            {
                MessageBox.Show(res2.message);
            }
        }

        /// <summary>
        /// 鼠标离开车号输入框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ch_Leave(object sender, EventArgs e)
        {
            if (ch.Text.Trim()!="")
            {
                var res = service.Get_FirstData(ch.Text.Trim());

                if (res.code==200)
                {
                    if (res.data!=null)
                    {
                        var gb_data = res.data as GB_First_Data;

                        jhh.Text = gb_data.czxh;
                        ycjl_data.Text = gb_data.pz.ToString();
                        ycjl_time.Text = gb_data.pzsj.ToString();
                        ycjl_bf.Text = gb_data.pzdd.ToString();
                        ycjl_time.Text = gb_data.pzsj.ToString();
                        ycjl_name.Text = gb_data.pzscy;
                        pm.SelectedValue = gb_data.pmm;
                        ly.Text = gb_data.ly;
                        qx.Text = gb_data.qx;
                        kz.Text = gb_data.kz.ToString();

                        first_cz.Visible = true;

                        if (zl.Text.Trim()!=""&&kz.Text.Trim()!="")
                        {
                            jz.Text = Math.Abs(decimal.Parse(zl.Text) - decimal.Parse(ycjl_data.Text) - decimal.Parse(kz.Text)).ToString();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(res.message);
                }
            }
        }

        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void save_Click(object sender, EventArgs e)
        {
            var res = service.Set_Gb_Data(jhh.Text, ch.Text, pm.SelectedValue.ToString(),
                ly.Text, qx.Text, zl.Text, ycjl_data.Text, ycjl_time.Text, kz.Text,
                bf.SelectedValue.ToString(), Single_Yh.GetYh().ID, jz.Text);
            if (res.code==200)
            {
                MessageBox.Show(res.message);
                InitForm();
            }
            else
            {
                MessageBox.Show(res.message);
            }
        }

        /// <summary>
        /// 重置窗口输入框
        /// </summary>
        private void InitForm()
        {
            ch.Text = "";
            pm.SelectedValue = -1;
            ly.Text = "";
            qx.Text = "";
            zl.Text = "";
            kz.Text = "";
            bf.SelectedValue = -1;
            jhh.Text = "";
            ycjl_bf.Text = "";
            ycjl_time.Text = "";
            ycjl_name.Text = "";
            jz.Text = "";
            first_cz.Visible = false;
        }

        /// <summary>
        /// 鼠标离开重量输入框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void zl_Leave(object sender, EventArgs e)
        {
            if (jhh.Text!=""&&kz.Text.Trim()!=""&& zl.Text.Trim() != "")
            {
                jz.Text = Math.Abs(decimal.Parse(zl.Text) - decimal.Parse(ycjl_data.Text) - decimal.Parse(kz.Text)).ToString();
            }
        }

        /// <summary>
        /// 一次计量无效按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ycjl_wx_Click(object sender, EventArgs e)
        {
            if (yhm.Text==""||password.Text=="")
            {
                MessageBox.Show("请填写用户信息");
                yhxx.Visible = true;
            }
            else
            {
                var res = service.Set_Gb_State(yhm.Text,password.Text,jhh.Text);

                if (res.code == 200)
                {
                    MessageBox.Show(res.message);
                    InitYcjl_Panel();
                }
                else
                {
                    MessageBox.Show(res.message);
                }
            }
        }

        /// <summary>
        /// 重置一次计量panel
        /// </summary>
        private void InitYcjl_Panel()
        {
            jhh.Text = "";
            ycjl_bf.Text = "";
            ycjl_time.Text = "";
            ycjl_name.Text = "";
            jz.Text = "";
            first_cz.Visible = false;

            yhm.Text = "";
            password.Text = "";
            yhxx.Visible = false;
        }

        /// <summary>
        /// 过磅数据查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gbcx_Click(object sender, EventArgs e)
        {
            this.Hide();
            GB_Data_Interface data = new GB_Data_Interface();
            data.ShowDialog();
            this.Close();
        }

        private void 测试ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form1 data = new Form1();
            data.ShowDialog();
            this.Close();
        }
    }
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值