示例#1
0
        private void SaveSalesman()
        {
            if (txtSalesmanName.Text == "")
            {
                MessageBox.Show("Nama harus diisi", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSalesmanName.Focus();
            }
            else if (formMode == FormMode.Add && salesmanRepository.IsSalesmanNameExisted(txtSalesmanName.Text))
            {
                MessageBox.Show("Salesman : " + txtSalesmanName.Text + "\n\n" + "sudah ada ", "Perhatian",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            else if (txtPhone1.Text == "")
            {
                MessageBox.Show("Telepon 1 harus diisi", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPhone1.Focus();
            }

            else
            {
                Salesman salesman = new Salesman();

                salesman.Name     = txtSalesmanName.Text;
                salesman.Phone1   = txtPhone1.Text;
                salesman.Phone2   = txtPhone2.Text;
                salesman.Address  = txtAddress.Text;
                salesman.Notes    = txtNotes.Text;
                salesman.IsActive = chkIsActive.Checked;

                if (formMode == FormMode.Add)
                {
                    salesmanRepository.Save(salesman);
                    GetLastSalesman();
                }
                else if (formMode == FormMode.Edit)
                {
                    salesman.ID = new Guid(txtID.Text);
                    salesmanRepository.Update(salesman);
                }

                LoadSalesmen();
                DisableForm();
                formMode  = FormMode.View;
                this.Text = "Salesman";
            }
        }
        public void EditTest()
        {
            var salesman = new Salesman
            {
                slsmCode     = "20180001",
                slsmName     = "RAHMAT HIDAYAT",
                slsmAddress  = "Perum Telaga Murni No.22 rt.2 rW. 69",
                slsmIdNumber = 31274000,
                slsmSupv     = "Munadi",
                slsmPhoto    = "tURURURURUR",
                slsmTelp     = "888921212"
            };

            var result = salesmanRepo.Update(salesman);

            Assert.IsTrue(result != 0);
        }