public static bool Insert(kem_gateway_bill_status _item) { bool result; using (SqlConnection connection = new SqlConnection(ConfigurationSettings.ConnectionStringSQL)) { string _sql = "INSERT INTO [dbo].[kem_gateway_bill_status] ( [so_van_don], [ma_trang_thai], [ma_kh], [created], [ghi_chu], [so_lan], [sync], [sync_ems], [sync_orc], [time_status], [sys_active], [sys_delete], [sys_createdate], [sys_updatedate], [sys_createby], [sys_updateby], [type], [sync_kes], [ma_nv_nhan], [ma_nv_giao] ) VALUES ( @so_van_don, @ma_trang_thai, @ma_kh, @created, @ghi_chu, @so_lan, @sync, @sync_ems, @sync_orc, @time_status, @sys_active, @sys_delete, @sys_createdate, @sys_updatedate, @sys_createby, @sys_updateby, @type, @sync_kes, @ma_nv_nhan, @ma_nv_giao )"; DynamicParameters p = new DynamicParameters(); p.Add("@so_van_don", _item.so_van_don); p.Add("@ma_trang_thai", _item.ma_trang_thai); p.Add("@ma_kh", _item.ma_kh); p.Add("@created", _item.created); p.Add("@ghi_chu", _item.ghi_chu); p.Add("@so_lan", _item.so_lan); p.Add("@sync", _item.sync); p.Add("@sync_ems", _item.sync_ems); p.Add("@sync_orc", _item.sync_orc); p.Add("@time_status", _item.time_status); p.Add("@sys_active", _item.sys_active); p.Add("@sys_delete", _item.sys_delete); p.Add("@sys_createdate", _item.sys_createdate); p.Add("@sys_updatedate", _item.sys_updatedate); p.Add("@sys_createby", _item.sys_createby); p.Add("@sys_updateby", _item.sys_updateby); p.Add("@type", _item.type); p.Add("@sync_kes", _item.sync_kes); p.Add("@ma_nv_nhan", _item.ma_nv_nhan); p.Add("@ma_nv_giao", _item.ma_nv_giao); int rowsAffected = connection.Execute(_sql, p, commandType: CommandType.Text); result = (rowsAffected > 0); } return(result); }
public ActionResult updateBillStatus(string onPUP, string onPUX) { string status = string.Empty; if (onPUP != null) { status = "PUP"; } if (onPUX != null) { status = "PUX"; } string so_van_don = Request["txtSoVanDon"].ToString(); string ma_nv_nhan = Request["txtMaNV"].ToString(); string ly_do = Request["txtLyDo"].ToString() == "" ? null : Request["txtLyDo"].ToString(); nc_billRepository nbr = new nc_billRepository(); kem_gateway_bill_status kgbs = new kem_gateway_bill_status(); nc_bill nb = new nc_bill(); nb = nbr.GetByWaybill(so_van_don); kgbs.so_van_don = so_van_don; if (nb == null) { return(Content("Waybill not found!!")); } kgbs.ma_trang_thai = status; if (onPUP != null) { kgbs.ma_nv_nhan = ma_nv_nhan; } kgbs.ma_kh = nb.customer_code_api; kgbs.ghi_chu = onPUP != null ? "Nhan hang thanh cong" : ly_do; kgbs.sys_createby = int.Parse(ma_nv_nhan); kgbs.sync = 0; kgbs.so_lan = 0; kgbs.sys_createdate = DateTime.Now; kgbs.time_status = kgbs.time_status == DateTime.MinValue ? DateTime.Now : kgbs.time_status; kgbs.sys_active = true; kgbs.sys_delete = false; kgbs.type = 8; bool i = kem_gateway_bill_statusRepository.Insert(kgbs); if (i) { return(Content("Succes!!")); } else { return(Content("Unsucces!!")); } }