Пример #1
0
 public static bool Update(BOLViewModel _bol)
 {
     try
     {
         using (IDbConnection db = new SQLiteConnection(DataAccess.GetConnectionString()))
         {
             string query = "UPDATE BOL " +
                            "SET txt1 =@txt1, txt2 =@txt2, txt3 =@txt3, txt4 =@txt4, txt5 =@txt5, txt6 =@txt6, txt7 =@txt7, txt8 =@txt8, txt9 =@txt9, txt10 =@txt10, txt11 =@txt11, txt12 =@txt12, txt13 =@txt13, txt14 =@txt14, txt15 =@txt15, txt16 =@txt16, txt17 =@txt17, txt18 =@txt18, txt19 =@txt19, txt20 =@txt20, txt21 =@txt21, txt22 =@txt22, txt23 =@txt23, txt24 =@txt24, txt25 =@txt25, txt26 =@txt26, txt27 =@txt27, txt28 =@txt28, txt29 =@txt29," +
                            "txt30 =@txt30, txt31 =@txt31, txt32 =@txt32, txt33 =@txt33, txt34 =@txt34, txt35 =@txt35, txt36 =@txt36, txt37 =@txt37, txt38 =@txt38, txt39 =@txt39, txt40 =@txt40, txt41 =@txt41, txt42 =@txt42, txt43 =@txt43, txt44 =@txt44, txt45 =@txt45, txt46 =@txt46, txt47 =@txt47, txt48 =@txt48, txt49 =@txt49, txt50 =@txt50, txt51 =@txt51, txt52 =@txt52, txt53 =@txt53, txt54 =@txt54, txt55 =@txt55, txt56 =@txt56, txt57 =@txt57," +
                            "txt58 =@txt58, txt59 =@txt59, txt60 =@txt60, txt61 =@txt61, txt62 =@txt62 Where ID=@ID";
             db.Execute(query, _bol);
         }
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
Пример #2
0
        //public static bool IsExistBol(string _bolNumber)
        //{
        //    var R = GetAllData().SingleOrDefault(s => s.txt2 == _bolNumber).ToString();
        //    return R.ToString() == "" ? false : true;
        //}

        public static bool Insert(BOLViewModel _bol)
        {
            try
            {
                using (IDbConnection db = new SQLiteConnection(DataAccess.GetConnectionString()))
                {
                    string query = "INSERT INTO BOL " +
                                   "(txt1, txt2, txt3, txt4, txt5, txt6, txt7, txt8, txt9, txt10, txt11, txt12, txt13, txt14, txt15, txt16, txt17, txt18, txt19, txt20, txt21, txt22, txt23, txt24, txt25, txt26, txt27, txt28, txt29, txt30, txt31, txt32, txt33, txt34, txt35, txt36, txt37, txt38," +
                                   "txt39, txt40, txt41, txt42, txt43, txt44, txt45, txt46, txt47, txt48, txt49, txt50, txt51, txt52, txt53, txt54, txt55, txt56, txt57, txt58, txt59, txt60, txt61, txt62)" +
                                   "VALUES(@txt1, @txt2, @txt3, @txt4, @txt5, @txt6, @txt7, @txt8, @txt9, @txt10, @txt11, @txt12, @txt13, @txt14, @txt15, @txt16, @txt17, @txt18, @txt19, @txt20, @txt21, @txt22, @txt23, @txt24, @txt25, @txt26, @txt27, @txt28, @txt29, @txt30, @txt31, @txt32, @txt33, @txt34, @txt35, @txt36, @txt37, @txt38, " +
                                   "@txt39, @txt40, @txt41, @txt42, @txt43, @txt44, @txt45, @txt46, @txt47, @txt48, @txt49, @txt50, @txt51, @txt52, @txt53, @txt54, @txt55, @txt56, @txt57, @txt58, @txt59, @txt60, @txt61, @txt62)";
                    db.Execute(query, _bol);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
Пример #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();
            }
        }
Пример #4
0
        public static string[] WriteBol(BOLViewModel _b)
        {
            string[] _str = new string[61];
            _str[0]  = _b.txt1;
            _str[1]  = _b.txt2;
            _str[2]  = _b.txt3;
            _str[3]  = _b.txt4;
            _str[4]  = _b.txt5;
            _str[5]  = _b.txt6;
            _str[6]  = _b.txt7;
            _str[7]  = _b.txt8;
            _str[8]  = _b.txt9;
            _str[9]  = _b.txt10;
            _str[10] = _b.txt11;
            _str[11] = _b.txt12;
            _str[12] = _b.txt13;
            _str[13] = _b.txt14;
            _str[14] = _b.txt15;
            _str[15] = _b.txt16;
            _str[16] = _b.txt17;
            _str[17] = _b.txt18;
            _str[18] = _b.txt19;
            _str[19] = _b.txt20;
            _str[20] = _b.txt21;
            _str[21] = _b.txt22;
            _str[22] = _b.txt23;
            _str[23] = _b.txt24;
            _str[24] = _b.txt25;
            _str[25] = _b.txt26;
            _str[26] = _b.txt27;
            _str[27] = _b.txt28;
            _str[28] = _b.txt29;
            _str[29] = _b.txt30;
            _str[30] = _b.txt31;
            _str[31] = _b.txt32;
            _str[32] = _b.txt33;
            _str[33] = _b.txt34;
            _str[34] = _b.txt35;
            _str[35] = _b.txt36;
            _str[36] = _b.txt37;
            _str[37] = _b.txt38;
            _str[38] = _b.txt39;
            _str[39] = _b.txt40;
            _str[40] = _b.txt41;
            _str[41] = _b.txt42;
            _str[42] = _b.txt43;
            _str[43] = _b.txt44;
            _str[44] = _b.txt45;
            _str[45] = _b.txt46;
            _str[46] = _b.txt47;
            _str[47] = _b.txt48;
            _str[48] = _b.txt49;
            _str[49] = _b.txt50;
            _str[50] = _b.txt51;
            _str[51] = _b.txt52;
            _str[52] = _b.txt53;
            _str[53] = _b.txt54;
            _str[54] = _b.txt55;
            _str[55] = _b.txt56;
            _str[56] = _b.txt57;
            _str[57] = _b.txt58;
            _str[58] = _b.txt59;
            _str[59] = _b.txt60;
            _str[60] = _b.txt61;
            //_str[61] = _b.txt62;

            return(_str.AddQutation());
        }