public object SaveRegister(FormSiriraj.Models.SirirajModel model) { //bool output = false; try { //Begin TranSaction Db.OpenFbData(); Db.BeginTransaction(); DataSet ds = new DataSet(); List <IDataParameter> parms = new List <IDataParameter>(); //var storeName = "INSERT INTO [SIP] ([ID],[Data]) VALUES (NEWID(),@Data) ;SELECT SCOPE_IDENTITY();"; var storeName = "sp_RegisterUser"; parms.Add(new SqlParameter("@CitizenID", model.CitizenID)); parms.Add(new SqlParameter("@ClearCitizenID", model.ClearCitizenID)); parms.Add(new SqlParameter("@Car", model.Car)); parms.Add(new SqlParameter("@Camera", model.Camera)); parms.Add(new SqlParameter("@Radio", model.Radio)); parms.Add(new SqlParameter("@Receipt", model.Receipt)); parms.Add(new SqlParameter("@DeliveryType", model.DeliveryType)); parms.Add(new SqlParameter("@BranchCode", model.BranchCode)); parms.Add(new SqlParameter("@BranchName", model.BranchName)); parms.Add(new SqlParameter("@BranchProvince", model.BranchProvince)); parms.Add(new SqlParameter("@Barcode", model.Barcode)); parms.Add(new SqlParameter("@QRcode", model.QRcode)); parms.Add(new SqlParameter("@Amount", model.Amount)); parms.Add(new SqlParameter("@Donate", model.Donate)); parms.Add(new SqlParameter("@TaxID", model.TaxID)); parms.Add(new SqlParameter("@Suffix", model.Suffix)); ds = Db.GetDataSet(storeName, parms, CommandType.StoredProcedure); DataTable dt = ds.Tables[0]; var query = (from temp in dt.AsEnumerable() select new { Result = temp.Field <Int32>("Result"), StockCar = temp.Field <Int32>("StockCar"), StockCamera = temp.Field <Int32>("StockCamera"), StockRadio = temp.Field <Int32>("StockRadio"), InvoiceID = temp.Field <Int32>("InvoiceID"), //CitizenID = temp.Field<String>("CitizenID"), Car = temp.Field <Int32>("Car"), Camera = temp.Field <Int32>("Camera"), Radio = temp.Field <Int32>("Radio"), Receipt = temp.Field <Int32>("Receipt"), DeliveryType = temp.Field <Int32>("DeliveryType"), BranchCode = temp.Field <String>("BranchCode"), BranchName = temp.Field <String>("BranchName"), BranchProvince = temp.Field <String>("BranchProvince"), Barcode = temp.Field <String>("Barcode"), QRcode = temp.Field <String>("QRcode"), Amount = temp.Field <Double>("Amount"), Donate = temp.Field <Double>("Donate"), Ref1 = temp.Field <String>("Ref1"), Ref2 = temp.Field <String>("Ref2"), CreateDate = temp.Field <DateTime>("CreateDate").ToString("yyyy/MM/dd HH:mm:ss") }); int CarStock = Convert.ToInt32(dt.Rows[0]["StockCar"]); int CameraStock = Convert.ToInt32(dt.Rows[0]["StockCamera"]); int RadioStock = Convert.ToInt32(dt.Rows[0]["StockRadio"]); //Set Strovk in Memory SetItemsStock(CarStock, CameraStock, RadioStock); bool IsbookItem = (Convert.ToInt32(dt.Rows[0]["Result"]) == 1); if (IsbookItem) { //Save PerSonale ============================================================================ model.personal.InvoiceID = Convert.ToInt32(dt.Rows[0]["InvoiceID"]); model.personal.CreateDate = Convert.ToDateTime(dt.Rows[0]["CreateDate"]); String JsonData = FromString.JsonToString(model.personal); List <IDataParameter> parmsData = new List <IDataParameter>(); var jsonEncrypt = Encryption.Encrypt(AppSettings.FormKey, JsonData); //parmsData.Add(Db.CreateParameterDb("@Data", JsonData)); parmsData.Add(new SqlParameter("@Data", jsonEncrypt)); Db.FbExecuteNonQuery("INSERT INTO [Personal]([Data],[CreateDate],[Status])VALUES(@Data, GETDATE(), 0)", parmsData, CommandType.Text); //============================================================================================= } Db.CommitTransaction(); Db.CloseFbData(); //Refresh Stock return(query.ToArray()); } catch (System.Exception ex) { Db.RollBackTransaction(); Db.CloseFbData(); throw ex; } }