//private List<StpriVM> stpri; //private List<DlvProfileVM> dlvprofile; public DealerEditDialog(DealerDialog dealer_dialog, DealerVM dealer) //, List<StpriVM> stpri, List<DlvProfileVM> dlvprofile { InitializeComponent(); this.main_form = dealer_dialog.main_form; this.dealer_dialog = dealer_dialog; this.dealer_id = dealer.Id; //this.dealer = dealer; //this.stpri = stpri; //this.dlvprofile = dlvprofile; }
private void GetAllDealers() { JObject allVehicleIDs; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://vautointerview.azurewebsites.net/api/"); var responseTask = client.GetAsync(VHelper.datasetId + "/vehicles"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readtask = result.Content.ReadAsAsync <JObject>(); readtask.Wait(); allVehicleIDs = readtask.Result; VHelper.arrOfIds = (JArray)allVehicleIDs["vehicleIds"]; VehicleVM tempV = null; DealerVM tempD = null; foreach (int jobj in VHelper.arrOfIds) { tempV = VHelper.vehicles.ContainsKey(jobj) ? VHelper.vehicles[jobj] : GetSingleVehicle(client, jobj); tempD = GetSingleDealer(client, tempV.dealerId); tempD.vehicles = new List <VehicleVM>() { tempV }; if (VHelper.dealers.ContainsKey(tempD.dealerId)) { //tempD.vehicles.AddRange(VHelper.dealers[tempD.dealerId].vehicles); if (!VHelper.dealers[tempD.dealerId].vehicles.Contains(tempV)) { VHelper.dealers[tempD.dealerId].vehicles.Add(tempV); } //VHelper.dealers.Remove(tempD.dealerId); } else { VHelper.dealers.Add(tempD.dealerId, tempD); } } } else { allVehicleIDs = null; throw new Exception("Server error. Please contact administrator."); } } }
public string updateDealer(DealerVM model) { var entity = _dbContext.Dealers.Find(model.Id); if (model != null) { entity.Name = model.Name; entity.Mobile = model.Mobile; entity.Address = model.Address; entity.Zipcode = model.Zipcode; entity.Email = model.Email; _dbContext.SaveChanges(); } return(entity.ToString()); }
public DealerVM getDealerById(int Id) { var entity = _dbContext.Dealers.Find(Id); DealerVM model = new DealerVM(); if (entity != null) { model.Name = entity.Name; model.Mobile = entity.Mobile; model.Address = entity.Address; model.Zipcode = entity.Zipcode; model.Email = entity.Email; } return(model); }
public JsonResult Insert_Dealer(DealerVM DealerVM) { bool result = false; string msg = "Failed to save record.."; DealerVM.Logo = Session["CompLogo"].ToString(); result = DealerMethods.Insert_Dealer(DealerVM, Session["DealerCode"].ToString()); if (result) { msg = "Successfully Added"; } return(Json(new { Success = result, Message = msg }, JsonRequestBehavior.AllowGet)); }
public string createDealer(DealerVM model) { if (model != null) { Database.Dealer dealer = new Database.Dealer(); dealer.Name = model.Name; dealer.Mobile = model.Mobile; dealer.Address = model.Address; //dealer.Locality = model.Locality; dealer.Zipcode = model.Zipcode; dealer.Email = model.Email; _dbContext.Dealers.Add(dealer); _dbContext.SaveChanges(); return(""); } return(""); }
public static bool Insert_Dealer(DealerVM model, string dealerCode) { try { string sql = "UPDATE Dealer SET [DealerDesc] = '" + model.DealerDesc + "' ,[Address1] = '" + model.Address1 + "',[SaleTaxNo] = '" + model.SaleTaxNo + "',[Phone1] = '" + model.Phone1 + "',[Phone2] = '" + model.Phone2 + "',[Email] = '" + model.Email + "',[Fax] = '" + model.Fax + "',[NTN] = '" + model.NTN + "'" + ",[UpdUser] = '" + AuthBase.UserId + "',[UpdDate] = '" + sysfun.SaveDate(DateTime.Now.ToString("dd/MM/yyyy")) + "',[UpdTerm] = '" + GlobalVar.mUserIPAddress + "'" + ",[Logo] = '" + model.Logo + "' WHERE DealerCode = '" + model.DealerCode + "'"; dt = sysfun.GetData(sql, "BMS0517ConnectionString"); IsSaved = true; } catch (Exception ex) { //ObjTrans.CommittTransaction(ref Trans); IsSaved = false; } return(IsSaved); }
private void DealerEditDialog_Load(object sender, EventArgs e) { this.splashScreenManager1.ShowWaitForm(); this.dealer = this.dealer_dialog.LoadSingerDealerFromServer(this.dealer_id); if (this.dealer == null) { this.DialogResult = DialogResult.Cancel; this.Close(); return; } this.cbDealerType.AddItem <DealerTypeObj>(this.GetDealerTypeObject()); this.cbStatus.AddItem <DealerStatusObj>(this.GetDealerStatusObject()); this.cbPriceCode.AddItem <StpriVM>(this.dealer_dialog.stpris); this.cbDlvProfile.AddItem <DlvProfileVM>(this.dealer_dialog.dlv_profiles); /** Display value in each control **/ this.txtDealerCode.Text = this.dealer.DealerCode; this.cbDealerType.SelectedIndex = this.cbDealerType.Properties.Items.IndexOf(this.cbDealerType.Properties.Items.Cast <DealerTypeObj>().Where(d => d.Value == this.dealer.DealerType).FirstOrDefault()); this.cbPriceCode.SelectedIndex = this.cbPriceCode.Properties.Items.IndexOf(this.cbPriceCode.Properties.Items.Cast <StpriVM>().Where(p => p.PriceCode == this.dealer.PriceCode).FirstOrDefault()); this.cbDlvProfile.SelectedIndex = this.cbDlvProfile.Properties.Items.IndexOf(this.cbDlvProfile.Properties.Items.Cast <DlvProfileVM>().Where(d => d.Id == this.dealer.DlvProfile).FirstOrDefault()); this.cbStatus.SelectedIndex = this.cbStatus.Properties.Items.IndexOf(this.cbStatus.Properties.Items.Cast <DealerStatusObj>().Where(d => d.Value == this.dealer.Status).FirstOrDefault()); this.txtSN.Text = this.dealer.SerNum; this.txtPreName.Text = this.dealer.PreName; this.txtName.Text = this.dealer.FullName; this.txtAddr01.Text = this.dealer.Addr01; this.txtAddr02.Text = this.dealer.Addr02; this.txtAddr03.Text = this.dealer.Addr03; this.txtZipCod.Text = this.dealer.ZipCod; this.txtTaxId.Text = this.dealer.TaxId; this.txtTelNum.Text = this.dealer.TelNum; this.txtFaxNum.Text = this.dealer.FaxNum; this.txtEmail.Text = this.dealer.UserName; this.splashScreenManager1.CloseWaitForm(); }
public DealerVM LoadSingerDealerFromServer(string dealer_id) { APIResult get = APIClient.GET(this.main_form.config.ApiUrl + "Dealers/GetDealerAt", this.main_form.config.ApiKey, "&id=" + dealer_id); if (get.Success) { DealerVM dealer = JsonConvert.DeserializeObject <DealerVM>(get.ReturnValue); return(dealer); } else { if (MessageBox.Show(get.ErrorMessage, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) { return(this.LoadSingerDealerFromServer(dealer_id)); } else { return(null); } } }
public List <DealerVM> getAllDealer() { var entities = _dbContext.Dealers.ToList(); List <DealerVM> dealerdata = new List <DealerVM>(); if (entities != null) { foreach (var item in entities) { DealerVM model = new DealerVM(); model.Name = item.Name; model.Mobile = item.Mobile; model.Address = item.Address; //dealer.Locality = model.Locality; model.Zipcode = item.Zipcode; model.Email = item.Email; dealerdata.Add(model); } } return(dealerdata); }
private DealerVM GetSingleDealer(HttpClient client, int dealerID) { DealerVM dealer = null; var responseTask = client.GetAsync(VHelper.datasetId + "/dealers/" + dealerID); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readtask = result.Content.ReadAsAsync <DealerVM>(); readtask.Wait(); dealer = readtask.Result; } else { throw new Exception("Server error. Please contact administrator."); } return(dealer); }
public string updateDealer(DealerVM model) { return(_dealerRepository.updateDealer(model)); }