Example #1
0
        public frmService(Model.Service model)
        {
            InitializeComponent();
            BLL.Service   bllService   = new BLL.Service();
            Model.Service modelService = bllService.GetModel(model.GUID);

            _model = modelService;
            _guid  = _model.customer;
        }
Example #2
0
        /// <summary>
        /// 获取新增服务编号
        /// </summary>
        private void GetServiceNo()
        {
            BLL.Argument bllArgument = new BLL.Argument();
            DataTable    dt          = bllArgument.GetList("type = '服务编号'").Tables[0];

            string str = dt.Rows[0][1].ToString();

            BLL.Service bllService = new BLL.Service();
            txtNO.Text = str + bllService.GetMaxID();
        }
Example #3
0
        /// <summary>
        /// 修改信息初始化
        /// </summary>
        private void GetUpdate()
        {
            this.Text = "编辑服务记录";
            BLL.Service   bll   = new BLL.Service();
            Model.Service model = bll.GetModel(_model.GUID);

            //赋值
            BLL.Argument bllArgument = new BLL.Argument();
            DataTable    dt          = bllArgument.GetList("type = '服务编号'").Tables[0];

            string str = dt.Rows[0][1].ToString();

            txtNO.Text      = str + model.sNO;
            dtpAccept.Value = model.acceptDate ?? DateTime.Now;

            if (_guid != Guid.Empty)
            {
                GetCustomerGroupAndSelected(_guid);
            }
            cbxType.Text = model.type;

            //服务内容
            if (!string.IsNullOrEmpty(model.content) &&
                model.content.Contains('ス'))
            {
                string[] content = model.content.Split('ス');

                if (content.Length == 2)
                {
                    txtFault.Text    = content[0];
                    txtSolution.Text = content[1];
                }
            }

            txtResult.Text        = model.result;
            cbxEvaluate.Text      = model.evaluate;
            txtMaterial.Text      = model.material;
            txtMaterialMoney.Text =
                string.Format("{0:F2}", model.materialMoney);
            txtServiceMoney.Text =
                string.Format("{0:F2}", model.serviceMoney);
            txtSum.Text =
                string.Format("{0:F2}",
                              model.materialMoney + model.serviceMoney);
            cbxPayStatus.Text = model.payStatus;
            dtpSolution.Value = model.solutionDate ?? DateTime.Now;
            cbxTraffic.Text   = model.traffic;
            cbxEmployee.Text  = model.employee;
        }
Example #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();

            if (string.IsNullOrEmpty(this.txtNO.Text.Trim()))
            {
                errorProvider1.SetError(txtNO, "服务编号不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.cbxName.Text.Trim()))
            {
                errorProvider1.SetError(cbxName, "客户名称不能为空!");
                return;
            }

            BLL.Service   bll   = new BLL.Service();
            Model.Service model = new Model.Service();
            model.sNO          = txtNO.Text.Substring(txtNO.Text.Length - 4);
            model.customer     = new Guid(cbxName.SelectedValue.ToString());
            model.acceptDate   = dtpAccept.Value;
            model.solutionDate = dtpSolution.Value;
            model.type         = cbxType.Text;
            model.content      = txtFault.Text.Trim() + "ス" +
                                 txtSolution.Text.Trim();
            model.result   = txtResult.Text.Trim();
            model.evaluate = cbxEvaluate.Text;
            model.material = txtMaterial.Text.Trim();

            decimal material = 0;

            if (string.IsNullOrEmpty(txtMaterialMoney.Text.Trim()) || decimal.TryParse(txtMaterialMoney.Text.Trim(),
                                                                                       out material))
            {
                model.materialMoney = material;
            }
            else
            {
                errorProvider1.SetError(txtMaterialMoney,
                                        "请输入正确的金额!");
                return;
            }

            decimal service = 0;

            if (string.IsNullOrEmpty(txtServiceMoney.Text.Trim()) || decimal.TryParse(txtServiceMoney.Text.Trim(),
                                                                                      out service))
            {
                model.serviceMoney = service;
            }
            else
            {
                errorProvider1.SetError(txtServiceMoney,
                                        "请输入正确的金额!");
                return;
            }

            model.payStatus = cbxPayStatus.Text;
            model.traffic   = cbxTraffic.Text;
            model.employee  = cbxEmployee.Text;

            bool flg = false;

            try
            {
                if (this.Text == "新增服务记录")
                {
                    flg = bll.Add(model);
                }
                else
                {
                    model.GUID = _model.GUID;
                    flg        = bll.Update(model);
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                MessageBox.Show("系统出错,请重试!");
                return;
            }

            if (flg)
            {
                MessageBox.Show("操作成功!");
            }
            else
            {
                MessageBox.Show("操作失败!");
            }

            if (((Control)sender).Name == "btnSave")
            {
                this.Close();
                this.Dispose();
                frmService frm = new frmService(_guid);
                frm.ShowDialog(frmMain.Main);
            }
            else
            {
                this.Close();
            }

            //刷新激活的窗体
            for (int i = 0; i < frmMain.Main.DockPanelMain.Contents.Count; i++)
            {
                if (frmMain.Main.DockPanelMain.Contents[i]
                    is dockService)
                {
                    dockService dock = (dockService)
                                       frmMain.Main.DockPanelMain.Contents[i];
                    dock.GetData();
                }
            }
        }