Ejemplo n.º 1
0
        private void SetStatus()
        {
            if (!MessageBoxEx.ShowQuestion(string.Format("确定要{0}吗?", btnStatus.Caption)))
            {
                if (vehInfo["status"].ToString() == ((int)DataSources.EnumStatus.Start).ToString())
                {
                    btnStatus.Caption = "启用";
                }
                else
                {
                    btnStatus.Caption = "停用";
                }
                return;
            }

            if (StatusSql())
            {
                MessageBoxEx.Show(btnStatus.Caption + "成功!");
                uc.BindData(vm_id);
                deleteMenuByTag(this.Tag.ToString(), uc.Name);
            }
            else
            {
                MessageBoxEx.ShowError(btnStatus.Caption + "失败!");
                if (vehInfo["status"].ToString() == ((int)DataSources.EnumStatus.Start).ToString())
                {
                    btnStatus.Caption = "启用";
                }
                else
                {
                    btnStatus.Caption = "停用";
                }
            }
        }
Ejemplo n.º 2
0
 //保存
 private void Save()
 {
     #region 验证输入的数据
     if (cboBrand.SelectedValue == null)
     {
         MessageBoxEx.Show("车辆品牌不能为空!");
         cboBrand.Focus();
         return;
     }
     if (cboType.SelectedValue == null)
     {
         MessageBoxEx.Show("车辆类型不能为空!");
         cboType.Focus();
         return;
     }
     if (txtCode.Caption.Length == 0)
     {
         MessageBoxEx.Show("车型编码不能为空!");
         txtCode.Focus();
         return;
     }
     if (txtName.Caption.Length == 0)
     {
         MessageBoxEx.Show("车型名称不能为空!");
         txtName.Focus();
         return;
     }
     if (MessageBoxEx.Show("确认要保存吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
     {
         return;
     }
     #endregion
     Dictionary <string, string> dic = new Dictionary <string, string>();
     dic.Add("v_brand", cboBrand.SelectedValue.ToString());
     dic.Add("vm_type", cboType.SelectedValue.ToString());
     dic.Add("vm_code", txtCode.Caption);
     dic.Add("vm_name", txtName.Caption);
     dic.Add("remark", txtRemark.Caption);
     //判断窗体状态
     if (status == WindowStatus.Add || status == WindowStatus.Copy)
     {
         dic.Add("data_source", ((int)DataSources.EnumDataSources.SELFBUILD).ToString());
         dic.Add("vm_id", Guid.NewGuid().ToString());
         dic.Add("enable_flag", ((int)DataSources.EnumEnableFlag.USING).ToString());
         dic.Add("status", ((int)DataSources.EnumStatus.Start).ToString());
         dic.Add("create_by", GlobalStaticObj.UserID);
         dic.Add("create_time", Common.LocalDateTimeToUtcLong(DateTime.Now).ToString());
         if (DBHelper.Submit_AddOrEdit("车型操作", "tb_vehicle_models", "", "", dic))
         {
             MessageBoxEx.Show("保存成功!");
             uc.BindData(vm_id);
             deleteMenuByTag(this.Tag.ToString(), this.uc.Name);
         }
         else
         {
             MessageBoxEx.Show("保存失败!");
         }
     }
     else if (status == WindowStatus.Edit)
     {
         dic.Add("update_by", GlobalStaticObj.UserID);
         dic.Add("update_time", Common.LocalDateTimeToUtcLong(DateTime.Now).ToString());
         if (DBHelper.Submit_AddOrEdit("车型操作", "tb_vehicle_models", "vm_id", vm_id, dic))
         {
             MessageBoxEx.Show("修改成功!");
             uc.BindData(vm_id);
             deleteMenuByTag(this.Tag.ToString(), this.uc.Name);
         }
         else
         {
             MessageBoxEx.Show("修改失败!");
         }
     }
 }