示例#1
0
 public ChargeDefineOptForm()
 {
     InitializeComponent();
     Init();
     m_chargeDefine = new ChargeDefine();
     entityFiller.DisplayEntity(m_chargeDefine);
 }
示例#2
0
 public Task <Tuple <bool, ChargeDefine, string> > SaveChargeDefine(ChargeDefine chargeDefine)
 {
     return(Task.Run(() => {
         var msg = "";
         var succ = true;
         var entity = chargeContext.chargeDefines.AsNoTracking().Where(p => p.ID.Equals(chargeDefine.ID)).FirstOrDefault();
         if (entity != null)
         {
             chargeContext.chargeDefines.Update(chargeDefine);
         }
         else
         {
             var entity1 = chargeContext.chargeDefines.AsNoTracking().Where(p => p.ItemName.Equals(chargeDefine.ItemName) &&
                                                                            p.Times.Equals(chargeDefine.Times)).FirstOrDefault();
             if (entity1 == null)
             {
                 chargeContext.chargeDefines.Add(chargeDefine);
             }
             else
             {
                 succ = false;
                 msg = "类型名称/代号已存在";
             }
         }
         chargeContext.SaveChanges();
         return new Tuple <bool, ChargeDefine, string>(succ, chargeDefine, msg);
     }));
 }
示例#3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgv.CurrentRow == null || dgv.CurrentRow.Index < 0)
                {
                    FrmTips.ShowTipsError(AppHelper.MainForm, "未选中任何行!", ContentAlignment.MiddleCenter, 1000);
                    return;
                }
                ChargeDefine entity = CGridHelper.GetCurrentData <ChargeDefine>(dgv);

                ConstantApi constantApi = new ConstantApi();
                var         resp        = constantApi.DeleteChargeDefine(entity.ID);
                //string sql = "DELETE ConstantType WHERE ID = @ID";
                //Hashtable hashtable = new Hashtable();
                //hashtable.Add("ID", entity.ID);
                //if (_mssqlHelper.ExcuteNonQuery(sql, hashtable) > 0)
                //{
                if (resp.Code == 1)
                {
                    FrmTips.ShowTipsSuccess(AppHelper.MainForm, "删除成功!", ContentAlignment.MiddleCenter, 1000);
                    CGridHelper.DeleteRow(dgv);
                }
                else
                {
                    FrmTips.ShowTipsError(AppHelper.MainForm, "删除失败!" + resp.Message, ContentAlignment.MiddleCenter, 1000);
                }
            }
            catch (Exception ex)
            {
                FrmTips.ShowTipsError(AppHelper.MainForm, "删除异常!" + ex.Message, ContentAlignment.MiddleCenter, 3000);
            }
        }
示例#4
0
        public ChargeDefineOptForm(ChargeDefine chargeDefine)
        {
            InitializeComponent();
            Init();
            m_chargeDefine = chargeDefine;
            entityFiller.DisplayEntity(m_chargeDefine);
            combDefine.SelectedText  = m_chargeDefine.ItemName;
            combDefine.SelectedValue = m_chargeDefine.ItemCode;

            txtTimes.Enabled   = false;
            combDefine.Enabled = false;
        }
示例#5
0
 public Task <ResponseModel> SaveChargeDefine(ChargeDefine constantDefine)
 {
     return(Task.Run(async() =>
     {
         ResponseModel response = new ResponseModel();
         var type = await m_constantService.SaveChargeDefine(constantDefine);
         response.Code = type.Item1 ? 1 : 0;
         response.Message = type.Item3;
         response.Data = type.Item2;
         response.DataCount = 1;
         return response;
     }));
 }
示例#6
0
 private void btnModify_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgv.CurrentRow == null || dgv.CurrentRow.Index < 0)
         {
             FrmTips.ShowTipsError(AppHelper.MainForm, "未选中任何行!", ContentAlignment.MiddleCenter, 1000);
             return;
         }
         ChargeDefine        entity = CGridHelper.GetCurrentData <ChargeDefine>(dgv);
         ChargeDefineOptForm form   = new ChargeDefineOptForm(entity);
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             btnSearch_Click(null, null);
         }
     }
     catch (Exception ex)
     {
         FrmTips.ShowTipsError(AppHelper.MainForm, "修改异常!" + ex.Message, ContentAlignment.MiddleCenter, 3000);
     }
 }
示例#7
0
 public ResponseModel SaveChargeDefine(ChargeDefine constantDefine)
 {
     return(apiHelper.ReqPost("ConstantDefine/SaveChargeDefine", constantDefine));
 }