public CustomerTransView(VisitaJayaPerkasa.Entities.CustomerTrans customerTrans)
        {
            InitializeComponent();
            sqlCustomerTransRepository = new SqlCustomerTransRepository();
            listCustomerTransDetail = sqlCustomerTransRepository.ListCustomerTransDetail(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;


            lblCustomerName.Text = customerTrans.CustomerName;
            lblDate.Text = Utility.Utility.GetDateOnly(Utility.Utility.ChangeDateMMDD(customerTrans.TransDate.ToString()));
        }
        public SearchCustomerTrans()
        {
            InitializeComponent();
            SqlCustomerTransRepository sqlCustomerTransRepository = new SqlCustomerTransRepository();
            listCustomerTrans = sqlCustomerTransRepository.ListCustomerTrans();

            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
            {
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            

            CustomerTransGridView.DataSource = listCustomerTrans;

            sqlCustomerTransRepository = null;
        }
        public RptDeliveryControl()
        {
            InitializeComponent();

            sqlCustomerRepository = new SqlCustomerRepository();
            sqlCustomerTransRepository = new SqlCustomerTransRepository();

            DateTime datetime = DateTime.Now;
            cboMonth.SelectedIndex = datetime.Month-1;
            spnYear.Value = datetime.Year;

            cboMonth.SelectedIndex = datetime.Month - 1;
            spnYear.Value = datetime.Year;

            List<VisitaJayaPerkasa.Entities.Customer> listCustomer = sqlCustomerRepository.ListCustomers();
            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);


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

            cboCustomer.SelectedIndex = 0;

            cboCustomer2.DataSource = listCustomer;
            cboCustomer2.DisplayMember = "CustomerName";
            cboCustomer2.ValueMember = "ID";
            cboCustomer2.SelectedIndex = -1;
            cboCustomer2.Text = "-- Choose --";

            cboTransDate.SelectedIndex = -1;
            cboTransDate.Text = "-- Choose --";

            cboTransDetail.SelectedIndex = -1;
            cboTransDetail.Text = "-- Choose --";

            cboCustomer2.SelectedIndexChanged += new EventHandler(Customer2_SelectedIndexChanged);

            cboCustomer2.SelectedIndex = 0;
        }
        public void LoadData()
        {
            sqlCustomerTransRepository = new SqlCustomerTransRepository();
            listCustomerTrans = null;

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

            listCustomerTrans = sqlCustomerTransRepository.ListCustomerTrans();

            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else if (listCustomerTrans != null)
            {
                if (!string.IsNullOrEmpty(searchValue) && !string.IsNullOrEmpty(searchKey))
                {
                    switch (searchKey)
                    {
                        case "Customer Name":
                            showListCustomerTrans = listCustomerTrans.Where(c => c.CustomerName.Contains(searchValue)).ToList<VisitaJayaPerkasa.Entities.CustomerTrans>();
                            break;
                    }

                }
                else
                    showListCustomerTrans = listCustomerTrans;
            }
            else
                showListCustomerTrans = null;

            if (showListCustomerTrans != null)
            {
                totalPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(showListCustomerTrans.Count() / Convert.ToDecimal(pageSize))));
                currentPage = 1;
            }
            else
                totalPage = 0;

            RefreshGrid();
        }
        private void radButtonElementRemove_Click(object sender, EventArgs e)
        {
            if (showListCustomerTrans != null)
            {
                sqlCustomerTransRepository = new SqlCustomerTransRepository();
                DialogResult dResult = MessageBox.Show(this, "Are you sure want delete master and detail this customer transaction ? ", "Confirmation", MessageBoxButtons.YesNo);
                if (dResult == DialogResult.Yes)
                {
                    GridViewRowInfo gridInfo = CustomerTransGridView.SelectedRows.First();
                    string id = gridInfo.Cells[0].Value.ToString();
                    SqlParameter[] sqlParam = SqlUtility.SetSqlParameter(new string[] { "id" }, new object[] { id });

                    if (sqlCustomerTransRepository.DeleteCustomerTrans(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;
                }
            }
        }
Пример #6
0
        public PrintLeadTime(Surat objSurat)
        {
            InitializeComponent();
            this.objSurat = objSurat;
            sqlCustomerTransRepository = new SqlCustomerTransRepository();
            reportDocument = new ReportDocument();
            paramFields = new ParameterFields();
            crtLeadTime = new CrtLeadTime();


            //Execute Query
            String strQry = "Select [CUSTOMER_TRANS_DETAIL].no_container as Column1, " + 
                "(Select Top 1 address From WareHouse Where stuffing_place_id = stuffing_place) as Column2, " + 
                "[CUSTOMER_TRANS_DETAIL].terima_toko as Column3 From [CUSTOMER_TRANS_DETAIL] " + 
                "Join [Customer_Trans] On " + 
                "[Customer_Trans].tgl_transaksi = cast('" + Utility.Utility.ConvertDateToString(objSurat.Tgl) + "' as date) And " + 
                "[Customer_Trans].Customer_id = '" + objSurat.CustomerID + "' And " + 
                "([Customer_Trans].deleted is not null Or [Customer_Trans].deleted = 0) " +
                "And [Customer_Trans].id = [Customer_Trans_Detail].customer_trans_id";

            int columnNo = 1;
            paramField = new ParameterField();
            paramField.Name = "col" + columnNo.ToString();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = "Container";
            paramField.CurrentValues.Add(paramDiscreteValue);
            paramFields.Add(paramField);
            columnNo++;

            paramField = new ParameterField();
            paramField.Name = "col" + columnNo.ToString();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = "Tgl penerimaan Container";
            paramField.CurrentValues.Add(paramDiscreteValue);
            paramFields.Add(paramField);
            columnNo++;

            paramField = new ParameterField();
            paramField.Name = "col" + columnNo.ToString();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = "Gudang";
            paramField.CurrentValues.Add(paramDiscreteValue);
            paramFields.Add(paramField);

            paramField = new ParameterField();
            paramField.Name = "noSurat";
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = objSurat.NoSurat;
            paramField.CurrentValues.Add(paramDiscreteValue);
            paramFields.Add(paramField);

            paramField = new ParameterField();
            paramField.Name = "parameterReceive";
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = objSurat.CustomerName;
            paramField.CurrentValues.Add(paramDiscreteValue);
            paramFields.Add(paramField);
            crystalReportViewer1.ParameterFieldInfo = paramFields;


            SqlConnection con = new SqlConnection(VisitaJayaPerkasa.Constant.VisitaJayaPerkasaApplication.connectionString);
            SqlDataAdapter da = new SqlDataAdapter(strQry, VisitaJayaPerkasa.Constant.VisitaJayaPerkasaApplication.connectionString);
            ShippingMainDataSet ds = new ShippingMainDataSet();
            da.Fill(ds, "Surat_Lead_Time");

            crtLeadTime.SetDataSource(ds);
            crystalReportViewer1.ReportSource = crtLeadTime;
        }
        private void radButtonElement1_Click(object sender, EventArgs e)
        {
            if (CustomerTransDetailGridView.Rows.Count > 0) {
                sqlCustomerTransRepository = new SqlCustomerTransRepository();
                if (cboCustomer.Text.Equals(Constant.VisitaJayaPerkasaApplication.cboDefaultText))
                    MessageBox.Show(this, "Please choose customer name", "Information");
                else { 

                    //51 is number of field below
                    int k = 0;
                    string[] key = new string[listCustomerTransDetail.Count * 51];
                    object[] value = new object[listCustomerTransDetail.Count * 51];

                    Guid TransID;
                    if (wantToCreateVessel)
                        TransID = Guid.NewGuid();
                    else
                        TransID = customerTrans.CustomerTransID;

                    for (int i = 0; i < listCustomerTransDetail.Count; i++) {
                        key[k] = "id";
                        value[k++] = listCustomerTransDetail.ElementAt(i).CustomerDetailTransID;

                        key[k] = "customer_trans_id";
                        value[k++] = TransID;

                        key[k] = "type_id";
                        value[k++] = listCustomerTransDetail.ElementAt(i).TypeID;

                        key[k] = "pelayaran_detail_id";
                        value[k++] = listCustomerTransDetail.ElementAt(i).PelayaranDetailID;

                        key[k] = "origin";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Origin;

                        key[k] = "destination";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Destination;

                        key[k] = "condition_id";
                        value[k++] = listCustomerTransDetail.ElementAt(i).ConditionID;

                        key[k] = "no_seal";
                        value[k++] = listCustomerTransDetail.ElementAt(i).NoSeal;

                        key[k] = "price";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Price;

                        key[k] = "stuffing_date";
                        value[k++] = listCustomerTransDetail.ElementAt(i).StuffingDate;

                        key[k] = "stuffing_place";
                        value[k++] = listCustomerTransDetail.ElementAt(i).StuffingPlace;

                        key[k] = "truck_number";
                        value[k++] = listCustomerTransDetail.ElementAt(i).TruckNo;

                        key[k] = "voy";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Voyage;

                        key[k] = "etd";
                        value[k++] = listCustomerTransDetail.ElementAt(i).ETD;

                        key[k] = "td";
                        value[k++] = listCustomerTransDetail.ElementAt(i).TD;

                        key[k] = "eta";
                        value[k++] = listCustomerTransDetail.ElementAt(i).ETA;

                        key[k] = "ta";
                        value[k++] = listCustomerTransDetail.ElementAt(i).TA;

                        key[k] = "unloading";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Unloading;

                        key[k] = "recipient_id";
                        value[k++] = listCustomerTransDetail.ElementAt(i).RecipientID;

                        key[k] = "jenis_barang";
                        value[k++] = listCustomerTransDetail.ElementAt(i).JenisBarang;

                        key[k] = "no_container";
                        value[k++] = listCustomerTransDetail.ElementAt(i).NoContainer;

                        key[k] = "quantity";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Quantity;

                        key[k] = "sj1";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj1;

                        key[k] = "sj2";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj2;

                        key[k] = "sj3";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj3;

                        key[k] = "sj4";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj4;

                        key[k] = "sj5";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj5;

                        key[k] = "sj6";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj6;

                        key[k] = "sj7";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj7;

                        key[k] = "sj8";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj8;

                        key[k] = "sj9";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj9;

                        key[k] = "sj10";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj10;

                        key[k] = "sj11";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj11;

                        key[k] = "sj12";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj12;

                        key[k] = "sj13";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj13;

                        key[k] = "sj14";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj14;

                        key[k] = "sj15";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj15;

                        key[k] = "sj16";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj16;

                        key[k] = "sj17";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj17;

                        key[k] = "sj18";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj18;

                        key[k] = "sj19";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj19;

                        key[k] = "sj20";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj20;

                        key[k] = "sj21";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj21;

                        key[k] = "sj22";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj22;

                        key[k] = "sj23";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj23;

                        key[k] = "sj24";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj24;

                        key[k] = "sj25";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Sj25;

                        key[k] = "terima_toko";
                        value[k++] = listCustomerTransDetail.ElementAt(i).TerimaToko;

                        key[k] = "keterangan";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Keterangan;

                        key[k] = "no_ba";
                        value[k++] = listCustomerTransDetail.ElementAt(i).NoBA;

                        key[k] = "deleted";
                        value[k++] = listCustomerTransDetail.ElementAt(i).Deleted;
                    }


                    SqlParameter[] sqlParameterInsert = SqlUtility.SetSqlParameter(key, value);
                    if (wantToCreateVessel)
                    {
                        SqlParameter[] sqlParameterMaster = SqlUtility.SetSqlParameter(
                            new string[] { "id", "customer_id", "tgl_transaksi", "deleted" },
                            new object[] { TransID, cboCustomer.SelectedValue, DateTime.Today, 0 }
                        );

                        if (sqlCustomerTransRepository.CreateCustomerTrans(sqlParameterInsert, sqlParameterMaster)) {
                            MessageBox.Show(this, "Success save data", "Information");
                            radButtonElement2.PerformClick();
                            sqlParameterMaster = null;
                        }
                        else
                            MessageBox.Show(this, "Cannot save data", "Information");
                    }
                    else {
                        SqlParameter[] sqlParameterMaster = SqlUtility.SetSqlParameter(
                            new string[] { "id", "customer_id" },
                            new object[] { TransID, cboCustomer.SelectedValue }
                        );

                        if (sqlCustomerTransRepository.EditCustomerTrans(sqlParameterInsert, sqlParameterMaster)) {                    
                            MessageBox.Show(this, "Success edit data", "Information");
                            radButtonElement2.PerformClick();
                            ID = TransID;
                            sqlParameterMaster = null;
                        }
                        else
                            MessageBox.Show(this, "Cannot edit data", "Information");
                    }

                        sqlCustomerTransRepository = null;
                        sqlParameterInsert = null;
                }
            }
            else
                MessageBox.Show(this, "Please fill transaction detail", "Information");
        }
        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;
            }
        }