Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要提交吗?", "", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            aft = this.PharmacyDatabaseService.GetApprovalFlowTypeByBusiness(out msg, ApprovalType.VehicleApproval).FirstOrDefault();

            if (aft == null)
            {
                MessageBox.Show("定义委托车辆需定义审批流程,请通知管理员定义该审批流程!");
                this.Dispose();
            }
            try
            {
                foreach (Control c in this.Controls)
                {
                    if (c.GetType() == typeof(TextBox))
                    {
                        if (string.IsNullOrEmpty(c.Text.Trim()))
                        {
                            MessageBox.Show("有未填项!", "警告");
                            c.Focus();
                            return;
                        }
                    }
                }

                m_Vehicle.Type                 = this.txtType.Text.Trim();
                m_Vehicle.Cubage               = this.txtCubage.Text.Trim();
                m_Vehicle.Rule                 = this.txtRule.Text.Trim();
                m_Vehicle.Other                = this.txtOther.Text.Trim();
                m_Vehicle.LicensePlate         = this.txtLicensePlate.Text.Trim();
                m_Vehicle.Driver               = this.txtDriver.Text.Trim();
                m_Vehicle.Status               = this.chkStatus.Checked;
                m_Vehicle.VehicleCategoryValue = this.comboBox1.SelectedIndex;
                m_Vehicle.createUID            = (Guid)BugsBox.Pharmacy.AppClient.Common.AppClientContext.CurrentUser.Id;
                m_Vehicle.DelegateMan          = this.txtDelegateMan.Text.Trim();
                m_Vehicle.DelegateCompany      = this.txtDelegateCompany.Text.Trim();
                m_Vehicle.DelegateTel          = this.txtDelegateTel.Text.Trim();
                m_Vehicle.LiscenceCode         = this.textBox2.Text.Trim();
                m_Vehicle.DelegateAddr         = this.textBox1.Text.Trim();
                m_Vehicle.StartDate            = this.dateTimePicker1.Value.Date;
                m_Vehicle.EndDate              = this.dateTimePicker2.Value.Date;
                m_Vehicle.DelegateScope        = this.textBox3.Text.Trim();


                if (m_state == FormOperation.Add)
                {
                    if (m_Vehicle.VehicleCategoryValue == 1)
                    {
                        m_Vehicle.FlowID = Guid.NewGuid();
                        bool b = this.PharmacyDatabaseService.AddVehicleToApprovalByFlowID(m_Vehicle, aft.Id, "新增委托车辆审批", out msg);
                        if (b)
                        {
                            MessageBox.Show("委托车辆信息新增成功!请通知委托车辆信息审批流程人员审查该信息!");
                        }
                    }
                    else
                    {
                        if (PharmacyDatabaseService.AddVehicle(out msg, m_Vehicle))
                        {
                            MessageBox.Show("自有车辆信息新增成功!");
                        }
                    }
                }
                else
                {
                    bool b = PharmacyDatabaseService.SaveVehicle(out msg, m_Vehicle);
                    if (b)
                    {
                        MessageBox.Show("保存成功!");
                    }
                }

                if (!string.IsNullOrEmpty(msg))
                {
                    MessageBox.Show(msg, "Error");
                    return;
                }

                ruslt = System.Windows.Forms.DialogResult.Yes;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存数据失败!", "系统错误");
                Log.Error(ex);
                this.Close();
            }
        }