private UniqueModel mapToModelSecret(DataRow item) { var result = new UniqueModel(); result.ID = Int32.Parse(item["ID"].ToString()); result.UniquID = Int32.Parse(item["UniquID"].ToString()); result.Date = item["Date"].ToString(); return(result); }
public void OneFromSix(string value, int unique) { var vm = new UniqueModel { Unique1 = value }; var validations = vm.Validate(vm.Unique1, _unique1); validations.Print(_output); Assert.Empty(validations); Assert.True(unique > 0); }
private void DraftRegister_Load(object sender, EventArgs e) { UsersCrud usersCrud = new UsersCrud(); UniqueCrud uniqueCrud = new UniqueCrud(); uniqueModel = uniqueCrud.GetLastUnique(); var users = usersCrud.findUsers(); txtUserID.DisplayMember = "Name"; txtUserID.ValueMember = "ID"; txtDate.Text = CommonUtils.ConvertMiladiToPersianDate(DateTime.Now.ToShortDateString()); foreach (var item in users) { var model = new ItemModel(); model.Name = item.name + " " + item.family; model.ID = item.ID; txtUserID.Items.Add(model); } txtTruck.DisplayMember = "Name"; txtTruck.ValueMember = "ID"; foreach (var item in CommonUtils.getTrucksType()) { txtTruck.Items.Add(item); } if (isForUpdate == true) { btnUpdate.Enabled = true; btnRegister.Enabled = false; DraftCrud draftCrud = new DraftCrud(); var draft = draftCrud.findDraftByID(DraftID); setElementsValue(draft); } if (isForUpdate == false) { fillForRegisterLoad(); } }
public void FourFromSix(string value, int unique) { var vm = new UniqueModel { Unique4 = value }; var validations = vm.Validate(vm.Unique4, _unique4); validations.Print(_output); if (unique >= 4) { Assert.Empty(validations); } else { Assert.Collection(validations, v => v.ErrorMessage = "4 unique characters are required"); } }
private void btnRegister_Click(object sender, EventArgs e) { if (txtCarTag.Text == "" || txtCertificateDriver.Text == "" || txtDate.Text == "" || txtDestination.Text == "" || txtDriver.Text == "" || txtManagement.Text == "" || txtNumber.Text == "" || txtOrigin.Text == "" || txtSerial.Text == "" || txtTruck.Text == "" || txtType.Text == "" || txtUserID.SelectedItem == null || txtValue.Text == "") { MessageBox.Show("اطلاعات را به صورت کامل وارد نمایید.", "خطا در ورود اطلاعات", MessageBoxButtons.OK); return; } if (ChekDateIsValid() == false) { return; } if (CheckIsCarTagValid() == false) { return; } var paramValues = bindFields(); if (MessageBox.Show("آیا اطلاعات ذخیره گردد. ", "ثبت اطلاعات", MessageBoxButtons.YesNo) == DialogResult.Yes) { DbContext context = new DbContext(); context.InsertData(DatabaseConstantData.DraftTable, paramValues); MessageBox.Show("اطلاعات با موفقیت ثبت گردید", "ثبت اطلاعات", MessageBoxButtons.OK); DraftCrud draftCrud = new DraftCrud(); var draft = draftCrud.findDraftByNumber(txtNumber.Text); var stiReport = CommonUtils.ShowReport(draft.ID); stiReport.Show(); List <TextBox> textBoxes = new List <TextBox>(); textBoxes.Add(txtCarTag); textBoxes.Add(txtCertificateDriver); textBoxes.Add(txtDate); textBoxes.Add(txtDestination); textBoxes.Add(txtDriver); textBoxes.Add(txtManagement); textBoxes.Add(txtNumber); textBoxes.Add(txtOrigin); textBoxes.Add(txtSerial); textBoxes.Add(txtValue); setNullToTextBox(textBoxes); if (DateTime.Now.ToShortDateString() != CommonUtils.ConvertPersianToMiladiDate(uniqueModel.Date).ToShortDateString()) { uniqueModel.UniquID = 1; } else { uniqueModel.UniquID++; } var paramsGenerate = bindFieldsGenerate(uniqueModel.UniquID); context.UpdateGenerate(DatabaseConstantData.GenerateTable, uniqueModel.ID, paramsGenerate); UniqueCrud uniqueCrud = new UniqueCrud(); uniqueModel = uniqueCrud.GetLastUnique(); fillForRegisterLoad(); } else { return; } }