public List<Customer> listCustomerForPriceList()
        {
            List<Customer> listCustomer = null;

            try
            {
                using (SqlConnection con = new SqlConnection(VisitaJayaPerkasa.Constant.VisitaJayaPerkasaApplication.connectionString))
                {
                    Constant.VisitaJayaPerkasaApplication.anyConnection = false;
                    con.Open();
                    Constant.VisitaJayaPerkasaApplication.anyConnection = true;

                    using (SqlCommand command = new SqlCommand(
                        "SELECT * FROM [Customer] WHERE (deleted is null OR deleted = '0')"
                        , con))
                    {
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            Customer customer = new Customer();
                            customer.ID = Utility.Utility.ConvertToUUID(reader.GetValue(0).ToString());
                            customer.CustomerName = (Utility.Utility.IsDBNull(reader.GetValue(1))) ? null : reader.GetString(1);
                            customer.Office = (Utility.Utility.IsDBNull(reader.GetValue(2))) ? null : reader.GetString(2);
                            customer.Address = (Utility.Utility.IsDBNull(reader.GetValue(3))) ? null : reader.GetString(3);
                            customer.Phone = (Utility.Utility.IsDBNull(reader.GetValue(4))) ? null : reader.GetString(4);
                            customer.Fax = (Utility.Utility.IsDBNull(reader.GetValue(5))) ? null : reader.GetString(5);
                            customer.Email = (Utility.Utility.IsDBNull(reader.GetValue(6))) ? null : reader.GetString(6);
                            customer.ContactPerson = (Utility.Utility.IsDBNull(reader.GetValue(7))) ? null : reader.GetString(7);
                            customer.StatusPPN = (Utility.Utility.IsDBNull(reader.GetValue(8))) ? 0 : Convert.ToInt32(reader.GetBoolean(8));
                            if (listCustomer == null)
                                listCustomer = new List<Customer>();

                            listCustomer.Add(customer);
                            customer = null;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logging.Error("SqlCustomerRepository.cs - listCustomerForPriceList() " + e.Message);
            }

            return listCustomer;
        }
Esempio n. 2
0
        private void btnClearAll_Click(object sender, EventArgs e)
        {
            listPriceDeleteExistsData.Clear();
            listIndexPriceDeleteExistsData.Clear();
            radButton2.Enabled = true;

            pickerTo.Enabled = true;
            pickerFrom.Enabled = true;
            cboTypeSupplier.Enabled = true;
            searchResultCustomer = null;
            txtCustomer.Text = "";

            if(cboTypeSupplier.Text.ToLower().Equals("dooring agent")){
                RefreshTypeSupplier();
                SetTypeOfSupplierDooringAgent();
                return;
            }


            cboTypeSupplier.SelectedItem = cboTypeSupplier.Items.ElementAt(0);
        }
Esempio n. 3
0
        /*
        private bool validateDate(VisitaJayaPerkasa.Entities.PriceList objPriceList, List<String> listID, List<VisitaJayaPerkasa.Entities.PriceList> priceList)
        {
            bool result = true;

            if (sqlPriceListRepository == null)
                sqlPriceListRepository = new SqlPriceListRepository();
            //query the db
            string customerID;
            if (searchResultCustomer != null)
                customerID = searchResultCustomer.ID.ToString();
            else
                customerID = Guid.Empty.ToString();
            int count = sqlPriceListRepository.FindPriceByDateSupplierCustomer(objPriceList.Date, listSupplier[cbSupplier.SelectedIndex].Id.ToString(), customerID);
            if (count > 0)
            {
                VisitaJayaPerkasa.Entities.PriceList oldPriceList = sqlPriceListRepository.GetPriceByDateSupplierCustomer(objPriceList.Date, listSupplier[cbSupplier.SelectedIndex].Id.ToString(), customerID);
                //decimal oldPrice = sqlPriceListRepository.GetSupplierPriceByDateSupplierCustomer(objPriceList.Date, listSupplier[cbSupplier.SelectedIndex].Id.ToString(), customerID);

                DialogResult dlgRes = DialogResult.Yes;
                if (objPriceList.PriceSupplier != oldPriceList.PriceSupplier)
                    dlgRes = MessageBox.Show("We already have price list on " + objPriceList.Date.ToString("dd/MMMM/yyyy") + ". Do you want to override supplier price to "+ objPriceList.PriceSupplier.ToString("#,###") +"?", "Data Duplication!", MessageBoxButtons.YesNo);
                if (dlgRes == DialogResult.Yes)
                {
                    //query the price id we want to override and set the current data id to existing
                    objPriceList.ID = oldPriceList.ID;
                    //add ID to deleted list
                    if (!listID.Contains(objPriceList.ID.ToString()))
                        listID.Add(objPriceList.ID.ToString());
                    for (int i = priceList.Count-1; i >= 0; i--)
                    {
                        if (priceList[i].ID.Equals(objPriceList.ID))
                            priceList.Remove(priceList[i]);
                    }
                    result = true;
                }
                else if (dlgRes == DialogResult.No)
                {
                    //check to the list. if exist, let it be. if not, cancel delete id
                    bool exist = false;
                    for (int i = priceList.Count - 1; i >= 0; i--)
                    {
                        if (priceList[i].ID.Equals(objPriceList.ID))
                        {
                            exist = true;
                            break;
                        }
                    }
                    if (exist)
                        listID.Remove(objPriceList.ID.ToString());
                    //remove this data from list
                    result = false;
                }
            }
            return result;
        }
         

        private bool validateTrucking(VisitaJayaPerkasa.Entities.PriceList objPriceList, List<String> listID, List<VisitaJayaPerkasa.Entities.PriceList> priceList)
        {
            bool result = true;

            if (sqlPriceListRepository == null)
                sqlPriceListRepository = new SqlPriceListRepository();
            //query the db
            string customerID;
            if (searchResultCustomer != null)
                customerID = searchResultCustomer.ID.ToString();
            else
                customerID = Guid.Empty.ToString();
            string msg = sqlPriceListRepository.FindPriceBySupplierCustomerStuffing(objPriceList.DateFrom, listSupplier[cbSupplier.SelectedIndex].Id.ToString(), customerID, listWarehouse[cboStuffingPlace.SelectedIndex].Id.ToString(), objPriceList.TypeID.ToString());
            if (msg != "")
            {
                VisitaJayaPerkasa.Entities.PriceList oldPriceList = sqlPriceListRepository.GetPriceBySupplierCustomerStuffing(objPriceList.DateFrom, listSupplier[cbSupplier.SelectedIndex].Id.ToString(), customerID, listWarehouse[cboStuffingPlace.SelectedIndex].Id.ToString(), objPriceList.TypeID.ToString());

                DialogResult dlgRes = DialogResult.Yes;
                if (objPriceList.PriceSupplier != oldPriceList.PriceSupplier || objPriceList.PriceCourier != oldPriceList.PriceCourier)
                    dlgRes = MessageBox.Show("We already have price list on:\n" + msg + ".\nDo you want to override supplier price to " + objPriceList.PriceSupplier.ToString("#,###") + " and courier price to " + objPriceList.PriceCourier.ToString("#,###") + "?", "Data Duplication!", MessageBoxButtons.YesNo);
                if (dlgRes == DialogResult.Yes)
                {
                    //query the price id we want to override and set the current data id to existing
                    objPriceList.ID = oldPriceList.ID;
                    //add ID to deleted list
                    if (!listID.Contains(objPriceList.ID.ToString()))
                        listID.Add(objPriceList.ID.ToString());
                    for (int i = priceList.Count - 1; i >= 0; i--)
                    {
                        if (priceList[i].ID.Equals(objPriceList.ID))
                            priceList.Remove(priceList[i]);
                    }
                    result = true;
                }
                else if (dlgRes == DialogResult.No)
                {
                    //check to the list. if exist, let it be. if not, cancel delete id
                    bool exist = false;
                    for (int i = priceList.Count - 1; i >= 0; i--)
                    {
                        if (priceList[i].ID.Equals(objPriceList.ID))
                        {
                            exist = true;
                            break;
                        }
                    }
                    if (exist)
                        listID.Remove(objPriceList.ID.ToString());
                    //remove this data from list
                    result = false;
                }
            }
            return result;
        }
         */

        private void cbDislayAll_ToggleStateChanged(object sender, StateChangedEventArgs args)
        {
            if (args.ToggleState == ToggleState.On)
            {
                searchResultCustomer = null;
                txtCustomer.Text = "";
                btnSearch.Enabled = false;
            }
            else
                btnSearch.Enabled = true;
        }
Esempio n. 4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            new SearchCustomer().ShowDialog();
            if (Constant.VisitaJayaPerkasaApplication.objGetOtherView != null)
            {
                searchResultCustomer = (VisitaJayaPerkasa.Entities.Customer)Constant.VisitaJayaPerkasaApplication.objGetOtherView;
                txtCustomer.Text = searchResultCustomer.CustomerName;
            }

            Constant.VisitaJayaPerkasaApplication.objGetOtherView = null;
        }