Com.Aote.ObjectTools.GeneralObject.Save C# (CSharp) Method

Save() public method

public Save ( ) : void
return void
        public void Save()
        {
            //有错误,不保存
            _errors.ToString();
            this._errors.ToString();

            //如果页面有错误内容,不能保存,提示错误.
            if (this.HasErrors)
            {
                string msg = "";
                foreach (KeyValuePair<string, string> kv in _errors)
                {
                    msg += "key=" + kv.Key + ", value=" + kv.Value + "\n";
                }
                MessageBox.Show(msg);
                return;
            }
            if (null != CustomePath && !"".Equals(CustomePath))
            {
                DBService.Get(WebClientInfo.BaseAddress + CustomePath).Invoke(this, SaveToJson);
            }
            else
            {
                DBService.Get(WebClientInfo.BaseAddress).Invoke(this, SaveToJson);
            }

           
        }
        #endregion

Usage Example

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //拿出datagrid所选数据
            GeneralObject go = OtherUserUnits.SelectedItem as GeneralObject;
            //拿出页面数据上下文
            GeneralObject updatehandplan = OtherUserUnit.DataContext as GeneralObject;
            //新建对象,往t_updatehandplan插入数据
            GeneralObject obj = new GeneralObject();
            try
            {
                obj.WebClientInfo = Application.Current.Resources["dbclient"] as WebClientInfo;
                obj.EntityType = "t_updateotherfee";
                obj.SetPropertyValue("f_userid", ui_userid.Text, false);
                obj.SetPropertyValue("f_username", ui_username.Text, false);
                obj.SetPropertyValue("f_address", ui_address.Text, false);
                obj.SetPropertyValue("f_sellid", go.GetPropertyValue("id").ToString(), false);


                obj.SetPropertyValue("f_feetype", go.GetPropertyValue("f_feetype").ToString(), false);
                obj.SetPropertyValue("f_newfeetype", ui_f_feetype.Text, false);
                obj.SetPropertyValue("f_fee", decimal.Parse(go.GetPropertyValue("f_fee").ToString()), false);
                obj.SetPropertyValue("f_newfee", decimal.Parse(ui_f_fee.Text), false);
                obj.SetPropertyValue("f_payfeevalid", go.GetPropertyValue("f_payfeevalid").ToString(), false);
                obj.SetPropertyValue("f_newpayfeevalid", ui_payfeevalid.SelectedValue, false);

                obj.SetPropertyValue("f_sellinggasoperator", ui_handplanoperator.Text, false);
                obj.SetPropertyValue("f_sellinggasdate", ui_handplandate.SelectedDate, false);
                obj.SetPropertyValue("f_updatenote", ui_updatenote.Text, false);
                obj.Name = "t_updateotherfee";
                //obj.Completed += obj_Completed;
                obj.Save();
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message);
            }
            //MessageBox.Show(go.GetPropertyValue("id").ToString());
           //  MessageBox.Show(ui_handplandate.SelectedDate.ToString());
            //oughtfee shifoujiaofei f_operator f_inputtor f_zhinajindate
            string sql = "update t_otherfee set f_feetype= '" + ui_f_feetype.Text +
              "',f_fee=" + decimal.Parse(ui_f_fee.Text) + ",f_payfeevalid='" + ui_payfeevalid.SelectedValue +
                 "' where id = " + go.GetPropertyValue("id");
           HQLAction action = new HQLAction();
           action.HQL = sql;
            action.WebClientInfo = Application.Current.Resources["dbclient"] as WebClientInfo;
            action.Name = "abc";
           action.Invoke();
            
            //如果数据有误,页面提示
            //回调页面保存按钮功能
            BatchExcuteAction save = (from p in loader.Res where p.Name.Equals("SaveAction") select p).First() as BatchExcuteAction;
            save.State = State.End;
            PagedObjectList save1 = (from p in loader.Res where p.Name.Equals("personlist") select p).First() as PagedObjectList;
            save1.IsOld = true;
            updatehandplan.New();
            
        }
All Usage Examples Of Com.Aote.ObjectTools.GeneralObject::Save