public newLeadTime(Surat objSurat, rptLeadTimeControl objParent) { InitializeComponent(); this.objParent = objParent; sqlCustomerRepository = new SqlCustomerRepository(); List<Customer> listCustomer = sqlCustomerRepository.listCustomerForPriceList(); cboCustomer.DataSource = listCustomer; cboCustomer.DisplayMember = "CustomerName"; cboCustomer.ValueMember = "ID"; if (objSurat == null) { surat = new Surat(); sqlSuratRepository = new SqlSuratRepository(); isCreateNew = true; Surat tempSurat = sqlSuratRepository.GetlastNoSurat(EnumSurat.LeadTime); String strTempNoSurat = (tempSurat == null) ? "0" : tempSurat.NoSurat.Substring(0, 4); etNoSurat.Text = surat.GenerateNoSurat(Int32.Parse(strTempNoSurat), EnumSurat.LeadTime); listCustomer = null; tempSurat = null; strTempNoSurat = null; sqlSuratRepository = null; } else { isCreateNew = false; surat = objSurat; etNoSurat.Text = objSurat.NoSurat; radDateTimePicker1.Value = objSurat.Tgl; cboCustomer.SelectedValue = objSurat.CustomerID; } sqlCustomerRepository = null; }
private void radButton2_Click(object sender, EventArgs e) { if (cboCustomer.Text.Equals(String.Empty)) MessageBox.Show(this, "No customer", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); else { sqlSuratRepository = new SqlSuratRepository(); SqlParameter[] sqlParam = SqlUtility.SetSqlParameter(new string[] { "No_Surat", "Tgl", "Customer_Id", "Supplier_Id" }, new object[] { etNoSurat.Text.Trim(), radDateTimePicker1.Value.Date, cboCustomer.SelectedValue, DBNull.Value}); if (isCreateNew) { if (sqlSuratRepository.CreateSurat(sqlParam)) { MessageBox.Show(this, "Success Create Surat", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); btnCancel.PerformClick(); } else if (!Constant.VisitaJayaPerkasaApplication.anyConnection) { MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { if (sqlSuratRepository.EditSurat(sqlParam)) { MessageBox.Show(this, "Success Edit Surat", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); btnCancel.PerformClick(); } else if (!Constant.VisitaJayaPerkasaApplication.anyConnection) { MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } }
private void cbSearch_SelectedIndexChanged(object sender, EventArgs e) { if (cbSearch.Text.ToLower().Equals("all")) { rtsiHal.Visibility = ElementVisibility.Collapsed; rtsiCustomer.Visibility = ElementVisibility.Collapsed; } else if (cbSearch.Text.ToLower().Equals("hal")) { rtsiHal.Visibility = ElementVisibility.Visible; rtsiCustomer.Visibility = ElementVisibility.Collapsed; sqlSuratRepository = new SqlSuratRepository(); listSurat = sqlSuratRepository.ListSurat(EnumSurat.LeadTime); cbHal.DataSource = listSurat; cbHal.DisplayMember = "NoSurat"; sqlSuratRepository = null; } else if (cbSearch.Text.ToLower().Equals("customer")) { rtsiHal.Visibility = ElementVisibility.Collapsed; rtsiCustomer.Visibility = ElementVisibility.Visible; SqlCustomerRepository sqlCustomerRepository = new SqlCustomerRepository(); List<Customer> listCustomer = sqlCustomerRepository.listCustomerForPriceList(); cboCustomer.DataSource = listCustomer; cboCustomer.DisplayMember = "CustomerName"; cboCustomer.ValueMember = "ID"; sqlCustomerRepository = null; listCustomer = null; } }
public void Search(string criteria) { sqlSuratRepository = new SqlSuratRepository(); if (criteria.ToLower().Equals("hal")) { if (cbHal.Text.Equals(Constant.VisitaJayaPerkasaApplication.cboDefaultText)) { MessageBox.Show(this, "Please choose hal", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); sqlSuratRepository = null; return; } else listSurat = sqlSuratRepository.ListSuratByCriteria(EnumSurat.LeadTime, lblDateBegin.Text, lblDateEnd.Text, cbHal.Text, null); } else if (criteria.ToLower().Equals("customer")) { if (cboCustomer.Text.Equals(Constant.VisitaJayaPerkasaApplication.cboDefaultText)) { MessageBox.Show(this, "Please choose customer", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); sqlSuratRepository = null; return; } else listSurat = sqlSuratRepository.ListSuratByCriteria(EnumSurat.LeadTime, lblDateBegin.Text, lblDateEnd.Text, null, cboCustomer.SelectedValue.ToString()); } else if (criteria.ToLower().Equals("all")) listSurat = sqlSuratRepository.ListSuratByCriteria(EnumSurat.LeadTime, lblDateBegin.Text, lblDateEnd.Text, null, null); else listSurat = sqlSuratRepository.ListSurat(EnumSurat.LeadTime); if (!Constant.VisitaJayaPerkasaApplication.anyConnection) MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); else radGridView1.DataSource = listSurat; sqlSuratRepository = null; }