Answer the question
In order to leave comments, you need to log in
Problems with Deserialization to a ready object. How to convert bool type to '1' or '0'?
The form has a CheckBox .
<ext:Checkbox ID="DELIVERY" runat="server"
Width="210"
FieldLabel="Рассылка"
LabelWidth="100"
MarginSpec="0 0 0 15">
</ext:Checkbox>
public partial class PERSON
{
public decimal ID { get; set; }
public string NAME { get; set; }
public string SURNAME { get; set; }
public string PASSPORT { get; set; }
public decimal SEX { get; set; }
public System.DateTime BORN { get; set; }
public decimal DELIVERY { get; set; }
public decimal CITY_ID { get; set; }
public virtual CITY CITY { get; set; }
}
<ext:Button ID="IDBUTTON" runat="server"
Text="Добавить"
Icon="Add"
Flat="true"
ToolTip="Добавить нового пользователя"
Cls="btnBackground"
Disabled="True">
<DirectEvents>
<Click OnEvent="AddNewUser"
After="Ext.Msg.alert('Сообщение','Пользователь добавлен');">
<ExtraParams>
<ext:Parameter
Name="values"
Value="#{FormPanel1}.getValues(false, false, true, true)"
Mode="Raw"
Encode="True"/>
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
[0] = {[NAME, Андрей]}
[1] = {[SURNAME, Андреанов]}
[2] = {[PASSPORT, 1221 212112]}
[3] = {[SEX, 1]}
[4] = {[COUNTRY, 1]}
[5] = {[CITY_ID, 2]}
[6] = {[BORN, 2015-10-29T00:00:00]}
[7] = {[DELIVERY, True]}
protected void AddNewUser(object Sender, DirectEventArgs e)
{
var objectParam = JsonConvert.DeserializeObject<PERSON>(e.ExtraParams["values"]);
var DB = new Entities();
DB.PERSON.Add(objectParam);
DB.SaveChanges();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question