private void AddItems(object sender, EventArgs e) { //validate date - date cannot in the past if (DateTime.Now > dateTimePickerConsignedDate.Value.AddMinutes(60)) { FormHelper.ShowErrorMessageBox("Date cannot in the past. \nPlease try again!"); return; } //validate consignor must be in autoCompleteConsignors if (autoCompleteConsignors.Contains(textBoxConsignor.Text.ToString())) { Consignor consignor = context.Consignors.Single(c => c.ConsignorEmail == textBoxConsignor.Text.ToString()); for (int i = 0; i < numericUpDownRepeat.Value; i++) { items.Add(new Item { ConsignorId = consignor.ConsignorId, ConsignedDate = dateTimePickerConsignedDate.Value, Price = numericUpDownPrice.Value, ItemStatus = ConsignmentStoreBusinessLogic.ITEM_STATUS_UNSOLD, ConsignedBy = ConsignmentStoreBusinessLogic.loggedInEmployee.EmployeeId }); } dataGridViewItems.DataSource = items.ToList();//update datagridview textBoxNumberOfItems.Text = items.Count.ToString(); textBoxTotalValue.Text = "$" + items.Sum(item => item.Price).ToString("n2"); } else { FormHelper.ShowErrorMessageBox("Consignor email does not exist. \nPlease try again or add new consignor!"); } }
public async Task <ActionResult> UpdateConsignor(int id, [FromBody] Consignor Consignor) { if (!ModelState.IsValid) { return(BadRequest(new ApiResponse { Status = false, ModelState = ModelState })); } try { var status = await _ConsignorsRepository.UpdateConsignorAsync(Consignor); if (!status) { return(BadRequest(new ApiResponse { Status = false })); } return(Ok(new ApiResponse { Status = true, Consignor = Consignor })); } catch (Exception exp) { _Logger.LogError(exp.Message); return(BadRequest(new ApiResponse { Status = false })); } }
public async Task <ActionResult> CreateConsignor([FromBody] Consignor Consignor) { if (!ModelState.IsValid) { return(BadRequest(new ApiResponse { Status = false, ModelState = ModelState })); } try { var newConsignor = await _ConsignorsRepository.InsertConsignorAsync(Consignor); if (newConsignor == null) { return(BadRequest(new ApiResponse { Status = false })); } return(CreatedAtRoute("GetConsignorRoute", new { id = newConsignor.Id }, new ApiResponse { Status = true, Consignor = newConsignor })); } catch (Exception exp) { _Logger.LogError(exp.Message); return(BadRequest(new ApiResponse { Status = false })); } }
public async Task <IActionResult> Edit(int id, [Bind("ConsignorID,City,FirstName,LastName")] Consignor consignor) { if (id != consignor.ConsignorID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(consignor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConsignorExists(consignor.ConsignorID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(consignor)); }
/// <summary> /// 获取所有的供应商 /// </summary> /// <returns></returns> public static List <Consignor> GetAllConsignor() { List <Consignor> list = new List <Consignor>(); string sql = "select * from c2lp_consignor order by linkType"; try { DataSet ds = _SqlHelp.ExecuteDataSet(sql, System.Data.CommandType.Text); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { Consignor c = new Consignor(); c.ConsignorId = Convert.ToInt32(row["ConsignorId"]); c.ConsignorName = row["ConsignorName"].ToString(); c.LinkType = row["LinkType"] is DBNull ? 0 : Convert.ToInt32(row["LinkType"]); c.LinkRegex = row["LinkRegex"] is DBNull ? string.Empty : row["LinkRegex"].ToString(); list.Add(c); } } } catch (Exception ex) { throw new Exception("请重新同步:" + ex.Message); } return(list); }
public AddEditConsignorForm(Consignor consignor) { InitializeComponent(); this.consignor = consignor; context = ConsignmentStoreBusinessLogic.context; //hide minimize and maximize buttons MinimizeBox = false; MaximizeBox = false; if (consignor == null) {//Add form this.Text = "Add Consignor"; buttonAddEdit.Text = "Add"; } else {//edit form this.Text = "Edit Consignor"; buttonAddEdit.Text = "Update"; //populate data to form textBoxName.Text = consignor.ConsignorName; dateTimePickerDOB.Value = (DateTime)consignor.ConsignorDOB; textBoxPhone.Text = consignor.ConsignorPhone; textBoxEmail.Text = consignor.ConsignorEmail; } buttonAddEdit.Click += AddEditAConsignor; }
public ConsignorDto(Consignor cons) { Id = cons.Id; DateAdded = cons.DateAdded; Consignor_Person = cons.Consignor_Person; ConsignorPmts_Consignor = cons.ConsignorPmts_Consignor; StoreCreditPmts_Consignor = cons.StoreCreditPmts_Consignor; StoreCreditTransactions_Consignor = cons.StoreCreditTransactions_Consignor; Items_Consignor = cons.Items_Consignor; }
private void AddConsignor(object sender, EventArgs e) { Consignor consignor = null; AddEditConsignorForm addEditConsignorForm = new AddEditConsignorForm(consignor); addEditConsignorForm.ShowDialog(); addEditConsignorForm.Dispose(); dataGridViewAll.Refresh(); }
public async Task <IActionResult> Create([Bind("ConsignorID,City,FirstName,LastName")] Consignor consignor) { if (ModelState.IsValid) { _context.Add(consignor); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(consignor)); }
static void Main(string[] args) { var consignor = new Consignor(); var dps = consignor.GetDropPoints("1523"); foreach (var dp in dps) { Console.WriteLine(dp.Name1); } Console.Read(); }
private void AddEditAConsignor(object sender, EventArgs e) { //validate inputs, not allow empty string if (textBoxName.Text.ToString() == "" || textBoxPhone.Text.ToString() == "" || textBoxEmail.Text.ToString() == "") { FormHelper.ShowErrorMessageBox("Please enter all required fields!"); return; } if (buttonAddEdit.Text.ToString() == "Add") { consignor = new Consignor(); consignor.ConsignorName = textBoxName.Text.ToString(); consignor.ConsignorDOB = dateTimePickerDOB.Value; consignor.ConsignorPhone = textBoxPhone.Text.ToString(); consignor.ConsignorEmail = textBoxEmail.Text.ToString(); context.Consignors.Add(consignor); try { context.SaveChanges(); } catch { FormHelper.ShowErrorMessageBox("Cannot add new consignor. Maybe email or phone number are taken. Please try again!"); return; } } else {//Update //FormHelper.ShowErrorMessageBox(consignor.ConsignorId+" id"); consignor.ConsignorName = textBoxName.Text.ToString(); consignor.ConsignorDOB = dateTimePickerDOB.Value; consignor.ConsignorPhone = textBoxPhone.Text.ToString(); consignor.ConsignorEmail = textBoxEmail.Text.ToString(); try { context.SaveChanges(); } catch { FormHelper.ShowErrorMessageBox("Cannot update a consignor. Maybe email or phone number are taken. Please try again!"); return; } } //success then close the form Close(); }
public int AddNewConsignor(Consignor consignor) { var input = new AddNewConsignorInput { Consignor = new ConsignorDto(consignor) }; using (var repo = new ConsignorRepository()) { var app = new ConsignorAppService(repo); return(app.AddNewConsignor(input).Id); } }
public void UpdateConsignor(Consignor updatedConsignor) { var input = new UpdateConsignorInput { Consignor = new ConsignorDto(updatedConsignor) }; using (var repo = new ConsignorRepository()) { var app = new ConsignorAppService(repo); app.UpdateConsignor(input); } }
//edit when double click private void EditConsignor(Object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0)//not header row { int consignorId = int.Parse(dataGridViewAll.Rows[e.RowIndex].Cells[0].Value.ToString()); Consignor consignor = context.Consignors.Find(consignorId); AddEditConsignorForm addEditConsignorForm = new AddEditConsignorForm(consignor); addEditConsignorForm.ShowDialog(); dataGridViewAll.Refresh(); } }
private void cboConsignors_SelectedIndexChanged(object sender, EventArgs e) { ResetReturnDelay(); _SelectConSignor = cboConsignors.SelectedItem as Consignor; if (_SelectConSignor.LinkType == 2) { FrmParent.ParentForm._isSelectLinkType2 = true; } else { FrmParent.ParentForm._isSelectLinkType2 = false; } }
public async Task <Consignor> InsertConsignorAsync(Consignor Consignor) { _Context.Add(Consignor); try { await _Context.SaveChangesAsync(); } catch (System.Exception exp) { _Logger.LogError($"Error in {nameof(InsertConsignorAsync)}: " + exp.Message); } return(Consignor); }
public async Task <bool> UpdateConsignorAsync(Consignor Consignor) { //Will update all properties of the Consignor _Context.Consignors.Attach(Consignor); _Context.Entry(Consignor).State = EntityState.Modified; try { return(await _Context.SaveChangesAsync() > 0 ? true : false); } catch (Exception exp) { _Logger.LogError($"Error in {nameof(UpdateConsignorAsync)}: " + exp.Message); } return(false); }
public override bool Equals(object obj) { var response = obj as TrackingInformationResponse; if (response == null) { return(false); } return (EstimatedTimeOfArrival == response.EstimatedTimeOfArrival && Events.Count() == response.Events.Count() && Consignor.Equals(response.Consignor) && Consignee.Equals(response.Consignee) && Status.Equals(response.Status)); }
public static string AddConsignor(Consignor consignor) { context.Consignors.Add(consignor); try { if (context.SaveChanges() > 0) { return(ADD_SUCCESS); } else { return(ADD_FAIL); } } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// 根据正则自动匹配运单归属的供运商 /// </summary> /// <param name="number"></param> public void AutoMatchConsignors(ref string number) { bool isMatch = false; foreach (Consignor item in cboConsignors.Items) { if (item.ConsignorId == -1 || string.IsNullOrEmpty(item.LinkRegex)) { continue; } if (Regex.IsMatch(number, item.LinkRegex)) { isMatch = true; _SelectConSignor = item; break; } } if (!isMatch) { throw new Exception("无法识别单号供应商"); } else if (_SelectConSignor.LinkType == 2) { string tempNumber = number; for (int i = 0; i < number.Length; i++) { string c = number[i].ToString(); if (c == "0") { tempNumber = tempNumber.Remove(0, 1); } else { break; } } number = tempNumber; } }
/// <summary> /// 还原当前选择的供应商 /// </summary> public void SelectedConsignors() { _SelectConSignor = cboConsignors.SelectedItem as Consignor; }
public string Get(int id) { Consignor c = new Consignor(); return(c.GetConsignorName(id.ToString())); }