예제 #1
0
        public void LoadDataInBackground()
        {
            sqlWareHouseRepository = new SqlWareHouseRepository();
            wareHouses = null;

            string searchValue = radTextBoxElementSearchWord.Text;
            string searchKey = radComboBoxElement.Text;

            wareHouses = sqlWareHouseRepository.GetWareHouse();

            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else if (wareHouses != null)
            {
                if (!string.IsNullOrEmpty(searchValue) && !string.IsNullOrEmpty(searchKey))
                {
                    switch (searchKey)
                    {
                        case "Address":
                            ShowWareHouse = wareHouses.Where(c => c.Address.Contains(searchValue)).ToList<Entities.WareHouse>();
                            break;
                        case "Phone":
                            ShowWareHouse = wareHouses.Where(c => c.Phone.Contains(searchValue)).ToList<Entities.WareHouse>();
                            break;
                    }

                }
                else
                    ShowWareHouse = wareHouses;
            }
            else
                ShowWareHouse = null;

            if (ShowWareHouse != null)
            {
                totalPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(ShowWareHouse.Count() / Convert.ToDecimal(pageSize))));
                currentPage = 1;
            }
            else
                totalPage = 0;
        }
예제 #2
0
        public PriceList()
        {
            InitializeComponent();
            sqlPriceListRepository = new SqlPriceListRepository();
            sqlCityRepository = new SqlCityRepository();
            sqlCustomerRepository = new SqlCustomerRepository();
            sqlRecipientRepository = new SqlRecipientRepository();
            sqlWareHouseRepository = new SqlWareHouseRepository();

            listPriceDeleteExistsData = new List<Guid>();
            listIndexPriceDeleteExistsData = new List<int>();

            listTypeOfSupplier = sqlPriceListRepository.GetTypeOfSupplier(0);
            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            cboTypeSupplier.SelectedValueChanged -= new EventHandler(cboTypeSupplier_SelectedValueChanged);
            cboTypeSupplier.DataSource = listTypeOfSupplier;
            cboTypeSupplier.DisplayMember = "CategoryName";
            cboTypeSupplier.ValueMember = "ID";
            cboTypeSupplier.SelectedIndex = -1;
            cboTypeSupplier.SelectedText = Constant.VisitaJayaPerkasaApplication.cboDefaultText;
            cboTypeSupplier.SelectedValueChanged += new EventHandler(cboTypeSupplier_SelectedValueChanged);

            listCity = sqlCityRepository.GetCity();
            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            cbDestination.DataSource = listCity;
            cbDestination.DisplayMember = "CityName";
            cbDestination.ValueMember = "ID";
            cbDestination.SelectedIndex = -1;
            cbDestination.SelectedText = Constant.VisitaJayaPerkasaApplication.cboDefaultText;



            listRecipient = sqlRecipientRepository.GetRecipient();
            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            cboRecipient.DataSource = listRecipient;
            cboRecipient.DisplayMember = "Name";
            cboRecipient.ValueMember = "ID";
            cboRecipient.SelectedIndex = -1;
            cboRecipient.SelectedText = Constant.VisitaJayaPerkasaApplication.cboDefaultText;

            listWarehouse = sqlWareHouseRepository.GetWareHouse();
            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            cboStuffingPlace.DataSource = listWarehouse;
            cboStuffingPlace.DisplayMember = "Address";
            cboStuffingPlace.ValueMember = "Id";
            cboStuffingPlace.SelectedIndex = -1;
            cboStuffingPlace.SelectedText = Constant.VisitaJayaPerkasaApplication.cboDefaultText;

            cbSupplier.Enabled = false;
            cboRecipient.Enabled = false;
            cbDislayAll.Visible = false;
            cbDislayAll.Enabled = false;
            sqlPriceListRepository = null;
            PriceListGridView.Enabled = false;
            sqlCityRepository = null;

            pickerFrom.Value = DateTime.Today;
            pickerTo.Value = DateTime.Today;
        }
예제 #3
0
        private void radButtonElement1_Click(object sender, EventArgs e)
        {
            if (etAddress.Text.Trim().Length == 0)
                MessageBox.Show(this, "Please fill address", "Information");
            else
            {
                SqlWareHouseRepository sqlWareHouseRepository = new SqlWareHouseRepository();

                SqlParameter[] param = SqlUtility.SetSqlParameter(new string[] { "address", /*"email", "contact_person"*/ }, new object[] { etAddress.Text.Trim()/*, etEmail.Text.Trim(), etContact.Text.Trim()*/ });


                if (wantToCreateVessel)
                {
                    VisitaJayaPerkasa.Entities.WareHouse warehouse = new VisitaJayaPerkasa.Entities.WareHouse();
                    warehouse.Id = Guid.NewGuid();
                    warehouse.Phone = etPhone.Text.Trim();
                    warehouse.Fax = etFax.Text.Trim();
                    warehouse.Email = etEmail.Text.Trim();
                    warehouse.Address = etAddress.Text.Trim();
                    warehouse.ContactPerson = etContact.Text.Trim();
                    warehouse.Deleted = 0;

                    if (sqlWareHouseRepository.CheckWarehouse(param, Guid.Empty, true))
                    {
                        DialogResult dResult = MessageBox.Show(this, "stuffing place has already deleted. Do you want to activate ?", "Confirmation", MessageBoxButtons.YesNo);
                        if (dResult == DialogResult.Yes)
                        {
                            SqlParameter[] parameters = SqlUtility.SetSqlParameter(new string[] { "stuffing_place_id", "address", "phone", "fax", "email", "contact_person", "deleted" }
                            , new object[] { warehouse.Id, warehouse.Address, warehouse.Phone, warehouse.Fax, warehouse.Email, warehouse.ContactPerson, warehouse.Deleted });

                            if (sqlWareHouseRepository.ActivateWarehouse(parameters))
                            {
                                MessageBox.Show(this, "Success Activate Stuffing Place", "Information");
                                radButtonElement2.PerformClick();
                            }
                            else if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            else
                                MessageBox.Show(this, "Cannot Activate Stuffing Place", "Information");

                            parameters = null;
                        }
                        return;
                    }
                    else if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                    {
                        MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else if (sqlWareHouseRepository.CheckWarehouse(param, Guid.Empty))
                    {
                        MessageBox.Show(this, "Stuffing Place has already exists", "Information");
                        return;
                    }
                    else if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                    {
                        MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    //Create user 
                    SqlParameter[] sqlParam = SqlUtility.SetSqlParameter(new string[] { "stuffing_place_id", "address", "phone", "fax", "email", "contact_person", "deleted" }
                            , new object[] { warehouse.Id, warehouse.Address, warehouse.Phone, warehouse.Fax, warehouse.Email, warehouse.ContactPerson, warehouse.Deleted });

                    if (sqlWareHouseRepository.CreateWareHouse(sqlParam))
                    {
                        MessageBox.Show(this, "Success create stuffing place", "Information");
                        radButtonElement2.PerformClick();
                    }
                    else if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                        MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                    {
                        MessageBox.Show(this, "Cannot Create stuffing place", "Information");
                    }
                }
                else
                {
                    warehouse.Id = this.warehouse.Id;
                    warehouse.Phone = etPhone.Text.Trim();
                    warehouse.Fax = etFax.Text.Trim();
                    warehouse.Email = etEmail.Text.Trim();
                    warehouse.Address = etAddress.Text.Trim();
                    warehouse.ContactPerson = etContact.Text.Trim();
                    warehouse.Deleted = 0;

                    if (sqlWareHouseRepository.CheckWarehouse(param, warehouse.Id))
                    {
                        MessageBox.Show(this, "Stuffing Place has already exist. if it has already deleted. you must activate it with create new data", "Information");
                        return;
                    }
                    else if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                    {
                        MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    SqlParameter[] sqlParam = SqlUtility.SetSqlParameter(new string[] { "stuffing_place_id", "address", "phone", "fax", "email", "contact_person", "deleted" }
                            , new object[] { warehouse.Id, warehouse.Address, warehouse.Phone, warehouse.Fax, warehouse.Email, warehouse.ContactPerson, warehouse.Deleted });

                    if (sqlWareHouseRepository.EditWareHouse(sqlParam))
                    {
                        MessageBox.Show(this, "Success edit stuffing place", "Information");
                        radButtonElement2.PerformClick();
                    }
                    else if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                        MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                    {
                        MessageBox.Show(this, "Cannot edit stuffing place", "Information");
                    }
                }


                //SqlParameter[] param;

                //if (wantToCreateVessel)
                //{
                //    //Check vessel code has already exists ?
                //    param = SqlUtility.SetSqlParameter(new string[] { "address" }, new object[] { etAddress.Text.Trim() });          
                //    param = null;
                //    param = SqlUtility.SetSqlParameter(new string[] { "stuffing_place_id", "address", "phone", "fax", "email", "contact_person", "deleted" }, new object[] { Guid.NewGuid(), etAddress.Text.Trim(), etPhone.Text.Trim(), etFax.Text.Trim(), etEmail.Text.Trim(), etContact.Text.Trim(),  0 });

                //    if (sqlWareHouseRepository.CheckWarehouseAddress(param, true))
                //        MessageBox.Show(this, "Address already exist", "Information");
                //    else
                //    {
                //        if (sqlWareHouseRepository.CreateWareHouse(param))
                //        {
                //            MessageBox.Show(this, "Success create warehouse", "Information");
                //            radButtonElement2.PerformClick();
                //        }
                //        else
                //        {
                //            MessageBox.Show(this, "Cannot Create warehouse", "Information");
                //        }
                //    }
                    
                //}
                //else
                //{
                //    param = SqlUtility.SetSqlParameter(new string[] { "stuffing_place_id", "address" }, new object[] { warehouse.Id, etAddress.Text.Trim()});
                //    if (sqlWareHouseRepository.CheckWarehouseAddress(param, true, true))
                //    {
                //        MessageBox.Show(this, "Address already exist", "Information");
                //        return;
                //    }

                //    param = SqlUtility.SetSqlParameter(new string[] { "address", "phone", "fax", "email", "contact_person", "stuffing_place_id" }, new object[] { etAddress.Text.Trim(), etPhone.Text.Trim(), etFax.Text.Trim(), etEmail.Text.Trim(), etContact.Text.Trim(), warehouse.Id });
                //    if (sqlWareHouseRepository.EditWareHouse(param))
                //    {
                //        MessageBox.Show(this, "Success Edit warehouse", "Information");
                //        radButtonElement2.PerformClick();
                //    }
                //    else
                //    {
                //        MessageBox.Show(this, "Cannot Edit warehouse", "Information");
                //    }
                //}

                //param = null;
                //sqlWareHouseRepository = null;
            }
        }
예제 #4
0
        private void radButtonElementRemove_Click(object sender, EventArgs e)
        {
            if (WareHouseGridView.SelectedRows.Count == 1)
            {
                sqlWareHouseRepository = new SqlWareHouseRepository();
                DialogResult dResult = MessageBox.Show(this, "Are you sure want delete this data ? ", "Confirmation", MessageBoxButtons.YesNo);
                if (dResult == DialogResult.Yes)
                {
                    GridViewRowInfo gridInfo = WareHouseGridView.SelectedRows.First();
                    string id = gridInfo.Cells[0].Value.ToString();
                    SqlParameter[] sqlParam = SqlUtility.SetSqlParameter(new string[] { "stuffing_place_id" }, new object[] { id });

                    if (sqlWareHouseRepository.DeleteWareHouse(sqlParam))
                    {
                        MessageBox.Show("Data Deleted !");
                        LoadData();
                    }
                    else if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                        MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                        MessageBox.Show("Cannot Delete Data !");

                    sqlParam = null;
                }
            }
        }
        public CustomerTransEdit(VisitaJayaPerkasa.Entities.CustomerTrans customerTrans)
        {
            InitializeComponent();
            this.customerTrans = customerTrans;
            
            sqlCustomerRepository = new SqlCustomerRepository();
            sqlTypeContRepository = new SqlTypeContRepository();
            sqlCityRepository = new SqlCityRepository();
            sqlPelayaranRepository = new SqlPelayaranRepository();
            sqlConditionRepository = new SqlConditionRepository();
            sqlPriceListRepository = new SqlPriceListRepository();
            sqlWarehouseRepository = new SqlWareHouseRepository();
            sqlRecipientRepository = new SqlRecipientRepository();
            sqlScheduleRepository = new SqlScheduleRepository();
            sqlTruckingRepository = new SqlTruckingRepository();
            sqlJenisBarangRepository = new SqlJenisBarangRepository();

            List<VisitaJayaPerkasa.Entities.Customer> listCustomer = sqlCustomerRepository.ListCustomers();
            List<VisitaJayaPerkasa.Entities.TypeCont> listType = sqlTypeContRepository.GetTypeCont();
            List<VisitaJayaPerkasa.Entities.City> listOrigin = sqlCityRepository.GetCity();
            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
            {
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List<VisitaJayaPerkasa.Entities.City> listDestination = sqlCityRepository.GetCity();
            List<VisitaJayaPerkasa.Entities.PelayaranDetail> listPelayaran = sqlPelayaranRepository.GetVessels();
            List<VisitaJayaPerkasa.Entities.Schedule> listSchedule = sqlScheduleRepository.ListSchedule();
            List<VisitaJayaPerkasa.Entities.Condition> listCondition = sqlConditionRepository.GetConditions();
            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
            {
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List<VisitaJayaPerkasa.Entities.WareHouse> listWarehouse;
            List<VisitaJayaPerkasa.Entities.Recipient> listRecipient;
            if (customerTrans != null)
            {
                listWarehouse = (this.customerTrans == null) ? sqlWarehouseRepository.GetWareHouse() : sqlWarehouseRepository.GetWareHouseByCustomer(customerTrans.CustomerID);
                listRecipient = (this.customerTrans == null) ? sqlRecipientRepository.GetRecipient() : sqlRecipientRepository.GetRecipientByCustomer(customerTrans.CustomerID);
            }
            else
            {
                listWarehouse = new List<Entities.WareHouse>();
                listRecipient = new List<Entities.Recipient>();
            }
            List<VisitaJayaPerkasa.Entities.Trucking> listTrucking = new List<Entities.Trucking>();
            List<VisitaJayaPerkasa.Entities.JenisBarang> listJenisBarang = sqlJenisBarangRepository.ListJenisBarang();
            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
            {
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            cboCustomer.DataSource = listCustomer;
            cboCustomer.DisplayMember = "CustomerName";
            cboCustomer.ValueMember = "ID";
            cboCustomer.SelectedIndex = -1;
            cboCustomer.Text = "-- Choose --";
            cboCustomer.Tag = "cboCustomer";
            
            cboType.DataSource = listType;
            cboType.DisplayMember = "TypeName";
            cboType.ValueMember = "ID";
            cboType.SelectedIndex = -1;
            cboType.Text = "-- Choose --";

            cboOrigin.DataSource = listOrigin;
            cboOrigin.DisplayMember = "CityName";
            cboOrigin.ValueMember = "ID";
            cboOrigin.SelectedIndex = -1;
            cboOrigin.Text = "-- Choose --";

            cboDestination.DataSource = listDestination;
            cboDestination.DisplayMember = "CityName";
            cboDestination.ValueMember = "ID";
            cboDestination.SelectedIndex = -1;
            cboDestination.Text = "-- Choose --";

            days = from p in listDestination 
                   select p.Days;

            cboPelayaranDetail.DataSource = listSchedule;
            cboPelayaranDetail.DisplayMember = "namaKapal";
            //cboPelayaranDetail.ValueMember = "ID";
            cboPelayaranDetail.SelectedIndex = -1;
            cboPelayaranDetail.Text = "-- Choose --";

            cboCondition.DataSource = listCondition;
            cboCondition.DisplayMember = "ConditionName";
            cboCondition.ValueMember = "ID";
            cboCondition.SelectedIndex = -1;
            cboCondition.Text = "-- Choose --";

            cboStuffingPlace.DataSource = listWarehouse;
            cboStuffingPlace.DisplayMember = "Address";
            cboStuffingPlace.ValueMember = "Id";
            cboStuffingPlace.SelectedIndex = -1;
            cboStuffingPlace.Text = "-- Choose --";

            cboRecipient.DataSource = listRecipient;
            cboRecipient.DisplayMember = "Name";
            cboRecipient.ValueMember = "ID";
            cboRecipient.SelectedIndex = -1;
            cboRecipient.Text = "-- Choose --";

            cboTrucking.DataSource = listTrucking;
            cboTrucking.DisplayMember = "TruckNo";
            cboTrucking.ValueMember = "ID";
            cboTrucking.SelectedIndex = -1;
            cboTrucking.Text = "-- Choose --";

            cboJenisBarang.DataSource = listJenisBarang;
            cboJenisBarang.DisplayMember = "Nama";
            cboJenisBarang.ValueMember = "Nama";
            cboJenisBarang.SelectedIndex = -1;
            cboJenisBarang.Text = "-- Type or Choose --";

            if (customerTrans == null)
            {
                wantToCreateVessel = true;
                listCustomerTransDetail = new List<Entities.CustomerTransDetail>();
            }
            else
            {
                wantToCreateVessel = false;
                cboCustomer.SelectedValue = customerTrans.CustomerID;
                cboCustomer.Enabled = false;

                SqlCustomerTransRepository sqlCustomerTransRepository = new SqlCustomerTransRepository();
                listCustomerTransDetail = sqlCustomerTransRepository.ListCustomerTransDetail(customerTrans.CustomerTransID);
                ID = customerTrans.CustomerTransID;

                if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                    MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                else if (listCustomerTransDetail != null)
                    CustomerTransDetailGridView.DataSource = listCustomerTransDetail;
                else
                    listCustomerTransDetail = new List<VisitaJayaPerkasa.Entities.CustomerTransDetail>();

                sqlCustomerTransRepository = null;
            }



            cboCustomer.SelectedIndexChanged += new EventHandler(cboSelected_SelectedIndexChanged);
            cboType.SelectedIndexChanged += new EventHandler(cboSelected_SelectedIndexChanged);
            cboDestination.SelectedIndexChanged += new EventHandler(cboSelected_SelectedIndexChanged);
            cboCondition.SelectedIndexChanged += new EventHandler(cboSelected_SelectedIndexChanged);


            sqlCustomerRepository = null;
            sqlTypeContRepository = null;
            sqlCityRepository = null;
            sqlPelayaranRepository = null;
            sqlConditionRepository = null;

            if (wantToCreateVessel)
            {
                dtpTD.Visible = false;
                dtpETA.Visible = false;
                dtpTA.Visible = false;
                dtpUnloading.Visible = false;
            }
        }