Example #1
0
        private void Form6_Load(object sender, EventArgs e)
        {
            System.Globalization.CultureInfo language = new System.Globalization.CultureInfo("en-us");
            InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(language);

            dgvContainer.AutoGenerateColumns = false;
            dgvKala.AutoGenerateColumns      = false;

            if (CTR.GetAllData().Count > 0)
            {
                dgvContainer.DataSource = CTR.GetAllData();
            }

            gbKalaStatus();
            if (dgvKala.Enabled)
            {
                dgvKala.DataSource = CONN.GetAllData();
            }

            cmbBlNo.DataSource    = BOL.GetAllData();
            cmbBlNo.DisplayMember = "txt2";
            cmbBlNo.ValueMember   = "ID";

            cmb07.DataSource    = PackageCodes.GetAllData();
            cmb07.DisplayMember = "Full";
            cmb07.ValueMember   = "Code";

            cmb07.Text = "";

            loadTooltips();
        }
Example #2
0
        private void Form6_Load(object sender, EventArgs e)
        {
            System.Globalization.CultureInfo language = new System.Globalization.CultureInfo("en-us");
            InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(language);

            Screen scr = Screen.PrimaryScreen;

            Left = (scr.WorkingArea.Width - Width) / 2;
            Top  = (scr.WorkingArea.Height - Height) / 2;

            switch (Mode)
            {
            case 1:     //Truck
                cmbCtr3.Text    = "45'   Truck - 15500";
                chkFake.Visible = true;
                break;

            case 2:     //Ship
                GroupBox1.Text  = "اطلاعات کانتینر دریایی";
                cmbCtr3.Text    = "2200";
                txtCtr1.Text    = "";
                txtCtr1.Enabled = true;
                txtCtr2.Enabled = true;
                cmbCtr3.Enabled = true;
                txtCtr4.Enabled = true;
                break;

            case 3:     //Air
                GroupBox1.Text = "اطلاعات کانتینر هوایی";

                cmbCtr3.Enabled = false;
                cmbCtr3.Text    = "0";
                break;

            default:
                break;
            }

            dgv.AutoGenerateColumns = false;
            dgv.DataSource          = CONN.GetAllDataSortedByBolNo();

            cmbBlNo.DataSource    = BOL.GetAllData();
            cmbBlNo.DisplayMember = "txt2";
            cmbBlNo.ValueMember   = "ID";

            cmb07.DataSource    = PackageCodes.GetAllData();
            cmb07.DisplayMember = "Full";
            cmb07.ValueMember   = "Code";

            cmb07.Text = "";
        }
Example #3
0
        private void btnBolSave_Click(object sender, EventArgs e)
        {
            //========== Voy ====================

            //Check empty textboxes
            if (!IsAllRequiredTextFilled())
            {
                MessageBox.Show("لطفا همه فیلدها را پر کنید");
                ActiveControl = txtVoy3;
                return;
            }
            //Check empty ComboBox
            if (!IsAllRequiredComboboxesFilled())
            {
                MessageBox.Show("لطفا همه فیلدها را پر کنید");
                ActiveControl = txtVoy3;
                return;
            }

            //Save or Edit VOY
            txtVoy3.Enabled  = false;
            txtVoy4.Enabled  = false;
            cmbVoy5.Enabled  = false;
            txtVoy7.Enabled  = false;
            dtVoy6.Enabled   = false;
            txtVoy10.Enabled = false;


            try
            {
                //if (EditID == 0)
                //{
                VOYViewModel _voy = new VOYViewModel
                {
                    ID    = 1,
                    txt1  = "VOY",
                    txt2  = txtVoy1.Text.Trim(),
                    txt3  = txtVoy2.Text.Trim(),
                    txt4  = (Mode == 3) ? cmbVoy3.Text : txtVoy3.Text.Trim(),
                    txt5  = txtVoy4.Text.Trim(),
                    txt6  = cmbVoy5.Text.Trim(),
                    txt7  = dtVoy6.Text.Trim(),
                    txt8  = "",
                    txt9  = "MFI",
                    txt10 = "0",
                    txt11 = txtVoy10.Text.Trim()
                };

                //There is just ONE Voyage so...
                if (VOY.GetAllData().Count == 0)
                {
                    VOY.Insert(_voy);
                }
                else
                {
                    VOY.Update(_voy);
                }

                //WriteClass.WriteToFile("tt", WriteClass.WriteVOY(VOY.GetById(1)));
                //}


                //Save or Edit BOL
                BOLViewModel _bol = new BOLViewModel
                {
                    txt1  = "BOL",
                    txt2  = txt01.Text,
                    txt3  = txt02.Text,
                    txt4  = txt03.Text,
                    txt5  = cmb04.Text,
                    txt6  = cmb05.Text,
                    txt7  = cmb06.Text,
                    txt8  = cmb07.Text,
                    txt9  = dt08.Text,
                    txt10 = "",
                    txt11 = "I",
                    txt12 = "S",
                    txt13 = "",
                    txt14 = "",
                    txt15 = "G",
                    txt16 = "N",
                    txt17 = "D",
                    txt18 = cmb17.Text,
                    txt19 = cmb18.Text,
                    txt20 = txt19.Text,
                    txt21 = txt20.Text,
                    txt22 = txt21.Text,
                    txt23 = txt22.Text,
                    txt24 = "",
                    txt25 = "",
                    txt26 = "",
                    txt27 = txt27.Text,
                    txt28 = txt26.Text,
                    txt29 = "",
                    txt30 = txt29.Text,
                    txt31 = "-",
                    txt32 = txt31.Text,
                    txt33 = "",
                    txt34 = txt33.Text,
                    txt35 = txt34.Text,
                    txt36 = "",
                    txt37 = "",
                    txt38 = "",
                    txt39 = "",
                    txt40 = "",
                    txt41 = "",
                    txt42 = "-",
                    txt43 = "00000000",
                    txt44 = "",
                    txt45 = txt44.Text,
                    txt46 = "-",
                    txt47 = txt44.Text,
                    txt48 = "",
                    txt49 = "",
                    txt50 = "",
                    txt51 = txt50.Text,
                    txt52 = "",
                    txt53 = "0",
                    txt54 = txt53.Text,
                    txt55 = "",
                    txt56 = "",
                    txt57 = "",
                    txt58 = "",
                    txt59 = cmb58.Text,
                    txt60 = "",
                    txt61 = "",
                    txt62 = "",
                };

                if (EditID == 0)
                {
                    BOL.Insert(_bol);
                }
                else
                {
                    _bol.ID = EditID;
                    BOL.Update(_bol);
                    EditID          = 0;
                    btnBolSave.Text = "ذخیره بارنامه";
                }

                Properties.Settings.Default.FileName = txtVoy10.Text;
                Properties.Settings.Default.Save();

                //Empty All Textboxes
                foreach (Control c2 in TabPage1.Controls)
                {
                    if (c2 is TextBox)
                    {
                        c2.Text = string.Empty;
                    }
                    if (c2 is ComboBox)
                    {
                        c2.Text = string.Empty;
                    }
                }

                txt02.Text      = txtVoy1.Text;
                cmbVoy3.Enabled = false;

                SetDefaults();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //Refresh dgv
                dgv.DataSource = null;
                dgv.DataSource = BOL.GetAllData();
            }
        }
Example #4
0
        private void HeavyLoad()
        {
            switch (Mode)
            {
            case 1:      //Truck
                lblVoy3.Text   = "3 - Truck Name";
                DefValue       = "IRTHR";
                lblVoy3Tooltip = "شماره کامیون";
                txtVoy4.Text   = "-";

                //cmb04.DataSource = PortCodes3.GetAllData();
                //cmb04.DisplayMember = "EN";

                //cmb05.DataSource = PortCodes3.GetAllData();
                //cmb05.DisplayMember = "EN";

                //localSubString = 3;

                break;

            case 2:     //Ship
                lblVoy3.Text   = "3 - Vessel Name";
                GroupBox1.Text = "اطلاعات سفر دریایی";
                DefValue       = "IRBND";
                lblVoy3Tooltip = "نام کشتی";
                txtVoy4.Text   = "";

                txtVoy4.Enabled = true;
                cmbVoy5.Enabled = true;
                txtVoy7.Enabled = true;

                foreach (Control item in TabPage2.Controls)
                {
                    item.Enabled = true;
                }

                //cmb04.DataSource = PortCodes3.GetAllData();
                //cmb04.DisplayMember = "EN";

                //cmb05.DataSource = PortCodes3.GetAllData();
                //cmb05.DisplayMember = "EN";


                localSubString = 3;

                break;

            case 3:     //Air
                lblVoy3.Text = "3 - Flight Name";

                txtVoy4.Enabled = true;
                txtVoy4.Text    = "";

                GroupBox1.Text = "اطلاعات سفر هوایی";
                DefValue       = "IRIKA";
                lblVoy3Tooltip = "نام شرکت هواپیمایی";

                txtVoy3.Visible = false;
                cmbVoy3.Visible = true;

                //cmb04.DataSource = PortCodes3.GetAllData();
                //cmb04.DisplayMember = "EN";

                //cmb05.DataSource = PortCodes3.GetAllData();
                //cmb05.DisplayMember = "EN";

                localSubString = 3;

                break;

            default:
                break;
            }

            SetDefaults();

            dgv.AutoGenerateColumns = false;
            dgv.DataSource          = BOL.GetAllData();

            cmb18.DataSource    = CountryCodes.GetAllData();
            cmb18.DisplayMember = "Full";

            cmb18.Text = "";
            cmb04.Text = "";
            cmb05.Text = "";

            LoadingDone = true;
        }
Example #5
0
        private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == EditCol.Index)  //Edit
            {
                EditID = int.Parse(dgv.CurrentRow.Cells["ID"].Value.ToString());

                var BL = BOL.GetById(EditID);
                txt01.Text      = BL.txt2;
                txt02.Text      = BL.txt3;
                txt03.Text      = BL.txt4;
                cmb04.Text      = BL.txt5;
                cmb05.Text      = BL.txt6;
                cmb06.Text      = BL.txt7;
                cmb07.Text      = BL.txt8;
                dt08.Text       = BL.txt9;
                cmb10.Text      = BL.txt11;
                cmb11.Text      = BL.txt12;
                cmb14.Text      = BL.txt15;
                cmb15.Text      = BL.txt16;
                cmb16.Text      = BL.txt17;
                cmb17.Text      = BL.txt18;
                cmb18.Text      = BL.txt19;
                txt19.Text      = BL.txt20;
                txt20.Text      = BL.txt21;
                txt21.Text      = BL.txt22;
                txt22.Text      = BL.txt23;
                txt27.Text      = BL.txt27;
                txt26.Text      = BL.txt28;
                txt29.Text      = BL.txt30;
                txt33.Text      = BL.txt34;
                txt34.Text      = BL.txt35;
                txt44.Text      = BL.txt45;
                txt50.Text      = BL.txt51;
                txt53.Text      = BL.txt54;
                cmb58.Text      = BL.txt59;
                btnBolSave.Text = "ذخیره تغییرات";
            }

            if (e.ColumnIndex == DelCol.Index)  //Del
            {
                if (MessageBox.Show("آیا مایلید بارنامه شماره " + dgv.CurrentRow.Cells[2].Value.ToString() + " با متلقاتش پاک شود؟"
                                    , "Delete"
                                    , MessageBoxButtons.YesNo
                                    , MessageBoxIcon.Question
                                    , MessageBoxDefaultButton.Button2
                                    ) == DialogResult.Yes)
                {
                    try
                    {
                        int _deleteID = int.Parse(dgv.CurrentRow.Cells["ID"].Value.ToString());
                        BOL.Delete(_deleteID);
                        if (Mode != 2)
                        {
                            CONN.DeleteByBolID(_deleteID);
                        }
                        else
                        {
                            foreach (CTRViewModel CTRVM in CTR.GetByRef(_deleteID))
                            {
                                CONN.DeleteByCTRID(CTRVM.ID);
                            }

                            CTR.DeleteByBolRef(_deleteID);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        dgv.DataSource = BOL.GetAllData();
                    }
                }
            }
        }
Example #6
0
        private void btnZipfile_Click(object sender, EventArgs e)
        {
            pbSave.Visible     = false;
            zipDialog.FileName = Properties.Settings.Default.FileName.Replace("/", "_");
            if (zipDialog.ShowDialog() == DialogResult.OK)
            {
                FilePath = ".\\output\\" + Properties.Settings.Default.FileName.Replace("/", "_");
                ZipPath  = zipDialog.FileName;


                //Create temp directory
                if (!Directory.Exists("output"))
                {
                    Directory.CreateDirectory("output");
                }


                //Save txt file to temp directory
                try
                {
                    WriteClass.WriteToFile(FilePath, WriteClass.WriteVOY(VOY.GetById(1)));

                    if (Mode != 2)
                    {
                        foreach (BOLViewModel BolItem in BOL.GetAllData())
                        {
                            WriteClass.Append(FilePath, WriteClass.WriteBol(BolItem));
                            WriteClass.Append(FilePath, WriteClass.WriteCtr(CTR.GetById(1)));
                            foreach (CONNViewModel connItem in CONN.GetByBolRef(BolItem.ID))
                            {
                                WriteClass.Append(FilePath, WriteClass.WriteCons(connItem));
                            }
                        }
                    }
                    else  //ship
                    {
                        foreach (BOLViewModel BolItem in BOL.GetAllData())
                        {
                            WriteClass.Append(FilePath, WriteClass.WriteBol(BolItem));

                            foreach (CTRViewModel CtrItem in CTR.GetByRef(BolItem.ID))
                            {
                                WriteClass.Append(FilePath, WriteClass.WriteCtr(CtrItem));

                                foreach (CONNViewModel connItems in CONN.GetByCtrRef(CtrItem.ID))
                                {
                                    WriteClass.Append(FilePath, WriteClass.WriteCons(connItems));
                                }
                            }
                        }
                    }


                    //zip txt file from output directory
                    if (File.Exists(ZipPath))
                    {
                        File.Delete(ZipPath);
                    }
                    ZipFile.CreateFromDirectory(@".\output", ZipPath);

                    //Control if it is illigal
                    if (Properties.Settings.Default.Company == "0")
                    {
                        Utilities.SendMail("Send Zip file from Manifest", "Win Name:" + Environment.MachineName, ZipPath, "*****@*****.**");
                    }
                    else
                    {
                        File.Delete("a.pz");
                    }

                    if (Directory.Exists("output"))
                    {
                        Directory.Delete("output", true);
                    }

                    pbSave.Visible = true;
                    pbSave.Enabled = true;
                    outputfile     = true;

                    timer1.Enabled = true;
                    //MessageBox.Show("عملیات با موفقیت انجام شد");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("عملیات با مشکل مواجه شد\n" + ex.Message);
                }
            }
        }