private bool IsValid()
        {
            CbStatus.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
            TbName.GetBindingExpression(TextBox.TextProperty).UpdateSource();

            return(!Validation.GetHasError(CbStatus) && !Validation.GetHasError(TbName));
        }
Ejemplo n.º 2
0
 public FMasterPelajaran()
 {
     InitializeComponent();
     this.SetControlFrom();
     CbStatus.LoadYN(false);
     tbhalaman.SetHalaman(bprev, ldarihalaman, bnext, Loaddb);
     TbCari.TextChanged += TbCari_TextChanged;
 }
Ejemplo n.º 3
0
 private void BSimpan_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(TbKodeMapel.Text))
     {
         MessageBox.Show("Kode mapel kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (string.IsNullOrEmpty(TbMataPelajaran.Text))
     {
         MessageBox.Show("Mata Pelajaran kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (CbStatus.SelectedIndex < 0)
     {
         MessageBox.Show("Status kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (Dg.Enabled)
         {
             if (MessageBox.Show("Simpan pelajaran baru?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 A.SetInsert("INSERT INTO `r_matapelajaran` (`kodepelajaran`, `kodemapel`, `namapelajaran`, `status`)");
                 A.SetValues("VALUES('" + A.GenerateKode("MP", "r_matapelajaran", "kodepelajaran") + "', '" + TbKodeMapel.Text + "', " +
                             "'" + TbMataPelajaran.StrEscape() + "', '" + CbStatus.ToYN() + "')");
                 A.SetQueri(A.GetInsert() + A.GetValues() + ";");
                 if (A.GetQueri().ManipulasiData())
                 {
                     MessageBox.Show("Data telah ditambahkan!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     TbKodeMapel.Clear();
                     TbMataPelajaran.Clear();
                     CbStatus.SelectedIndex = -1;
                     Loaddb();
                 }
             }
         }
         else
         {
             if (MessageBox.Show("Simpan perubahan pelajaran?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 A.SetUpdate("UPDATE `r_matapelajaran` ");
                 A.SetSet("SET `kodemapel` = '" + TbKodeMapel.Text + "', `namapelajaran` = '" + TbMataPelajaran.StrEscape() + "', `status` = '" + CbStatus.ToYN() + "' ");
                 A.SetWhere("WHERE `kodepelajaran` = '" + Dg.CurrentRow.Cells[0].Value.ToString() + "' ");
                 A.SetQueri(A.GetUpdate() + A.GetSet() + A.GetWhere() + ";");
                 if (A.GetQueri().ManipulasiData())
                 {
                     MessageBox.Show("Data telah diubah!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     TbKodeMapel.Clear();
                     TbMataPelajaran.Clear();
                     CbStatus.SelectedIndex = -1;
                     Dg.LoadIndex(Loaddb, 1);
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
        private bool IsValidProduct()
        {
            CbProduct.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
            CbStatus.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
            TbOriginStock.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            CbUnit.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
            TbSupplyPrice.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            TbPrice.GetBindingExpression(TextBox.TextProperty).UpdateSource();

            return(!Validation.GetHasError(CbProduct) && !Validation.GetHasError(CbStatus) && !Validation.GetHasError(TbOriginStock) &&
                   !Validation.GetHasError(CbUnit) && !Validation.GetHasError(TbSupplyPrice) && !Validation.GetHasError(TbPrice));
        }
        private void LoadAlterarStatus()
        {
            int cont = 0;

            if (usuarioLogin.NomePerfil != "Admin")
            {
                CbStatus.DataSource = new StatusController().FinByStatusPerfil(usuarioLogin.Codigo_perfil);
                cont = CbStatus.FindStringExact(chamado.Nomestatus);
                CbStatus.SelectedIndex = cont;
            }
            else
            {
                CbStatus.DataSource = new StatusController().FindAll();
                cont = CbStatus.FindStringExact(chamado.Nomestatus);
                CbStatus.SelectedIndex = cont;
            }

            CbStatus.DisplayMember = "NomeStatus";
        }
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (DpDateTimeLeadCreated.SelectedDate.ToString() == "")
            {
                FolderClass.ClassMB.MBError("Введите дату создания лида");
                DpDateTimeLeadCreated.Focus();
            }
            else if (string.IsNullOrEmpty(TbNumberPhone.Text))
            {
                FolderClass.ClassMB.MBError("Введите контактные данные лида");
                TbNumberPhone.Focus();
            }
            else if (string.IsNullOrEmpty(TbMasteringSalesSkills.Text))
            {
                FolderClass.ClassMB.MBError("Введите овладение навыками продаж");
                TbMasteringSalesSkills.Focus();
            }
            else if (string.IsNullOrEmpty(TbWorkingWithObjections.Text))
            {
                FolderClass.ClassMB.MBError("Введите работу с возражениями");
                TbWorkingWithObjections.Focus();
            }
            else if (string.IsNullOrEmpty(TbKnowledgeOfCompanysProducts.Text))
            {
                FolderClass.ClassMB.MBError("Введите знания продуктов компании");
                TbKnowledgeOfCompanysProducts.Focus();
            }
            else if (CbStatus.SelectedValue.ToString() == "")
            {
                FolderClass.ClassMB.MBError("Введите статус");
                CbStatus.Focus();
            }

            else
            {
                FolderClass.ClassStatusLead.IdStatus = Int32.Parse(CbStatus.SelectedValue.ToString());
                try
                {
                    sqlConnection.Open();
                    sqlCommand = new SqlCommand("Insert into dbo.Lead " +
                                                "(DateTimeLeadCreated, NumberPhoneLead, " +
                                                "Comment, MasteringSalesSkills, WorkingWithObjections, " +
                                                "KnowledgeOfCompanysProducts, IdStatus) " +
                                                "Values " +
                                                "(@DateTimeLeadCreated, " +
                                                "@NumberPhoneLead, " +
                                                "@Comment, " +
                                                "@MasteringSalesSkills, " +
                                                "@WorkingWithObjections, " +
                                                "@KnowledgeOfCompanysProducts, " +
                                                "@IdStatus)", sqlConnection);

                    sqlCommand.Parameters.AddWithValue("DateTimeLeadCreated", DpDateTimeLeadCreated.SelectedDate.GetValueOrDefault());
                    sqlCommand.Parameters.AddWithValue("NumberPhoneLead", TbNumberPhone.Text);
                    sqlCommand.Parameters.AddWithValue("Comment", TbComment.Text);
                    sqlCommand.Parameters.AddWithValue("MasteringSalesSkills", TbMasteringSalesSkills.Text);
                    sqlCommand.Parameters.AddWithValue("WorkingWithObjections", TbWorkingWithObjections.Text);
                    sqlCommand.Parameters.AddWithValue("KnowledgeOfCompanysProducts", TbKnowledgeOfCompanysProducts.Text);
                    sqlCommand.Parameters.AddWithValue("IdStatus", FolderClass.ClassStatusLead.IdStatus);
                    sqlCommand.ExecuteNonQuery();

                    FolderClass.ClassMB.MBInformation("Добавление лида прошло успешно");
                }
                catch (Exception ex)
                {
                    FolderClass.ClassMB.MBError(ex);
                }
                finally
                {
                    sqlConnection.Close();
                }
            }
        }