/// <summary>
 /// Create a new internet object.
 /// </summary>
 /// <param name="user_name">Initial value of the user_name property.</param>
 public static internet Createinternet(global::System.String user_name)
 {
     internet internet = new internet();
     internet.user_name = user_name;
     return internet;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the internets EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTointernets(internet internet)
 {
     base.AddObject("internets", internet);
 }
        void SaveData()
        {
            if (App.id_goicuoc == "" && cmbgoith.SelectedIndex !=-1)
            {
                MessageBox.Show("Chưa chọn thuê bao tích hợp !");
                return;
            }
            try
            {
                // get_hopdong(App.ma_huyen + "/" + this.dngayhd.DateTime.Year.ToString().Substring(2, 2));
                internet ds = new internet
                {
                    user_name = this.txtusr.Text.Trim(),                    
                    ten_dktb = this.txttentb.Text.Trim(),
                    ten_nsd = this.txttendb.Text.Trim(),
                    dia_chitb = this.txtdctb.Text.Trim(),
                    dc_tbld = this.txtdcld.Text.Trim(),
                    sohopdong = this.txtsohd.Text.Trim(),
                    ngay_hd = this.dngayhd.DateTime,
                    tuyen_tc = "",
                    goi_cuoc = cmbgoicuoc.GetKeyValue(cmbgoicuoc.SelectedIndex).ToString(),
                    toc_do = cmbtocdo.GetKeyValue(cmbtocdo.SelectedIndex).ToString(),
                    so_dt=this.txtsdt.Text.Trim(),
                    ma_dv = cmbdichvu.GetKeyValue(cmbdichvu.SelectedIndex).ToString(),
                    ht_ld =this.cmbhtld.Text.Trim()=="" ? "0": this.cmbhtld.Text.Trim().Substring(0, 1),
                    ma_huyen = App.ma_huyen,
                    socmnd = this.txtcmnd.Text.Trim(),
                    noi_cap = this.txtnoicap.Text.Trim(),
                    ngay_cap = this.dngaycap.DateTime,
                    ma_kh = this.txtmakh.Text,
                    ma_tram = cmbtramvt.GetKeyValue(cmbtramvt.SelectedIndex).ToString(),
                    kh_uutien = cmbkhuutien.GetKeyValue(cmbkhuutien.SelectedIndex).ToString().Trim(),
                    may_ngung="M",
                    ht_tt = cmbhttt.Text.Trim(),
                    ngay_kn = this.dngaykn.DateTime,
                    note_ngay_kn = this.txtghichu.Text,                    
                    tenkhkd = FunAndPro.KhongDau(this.txttentb.Text.Trim()),
                    dckd = FunAndPro.KhongDau(this.txtdctb.Text.Trim()),
                    ms_thue = FunAndPro.ma_st(this.txtmst.Text.Trim()),                  
                    duong = App.duong,
                    xa_phuong = App.phuong,
                    khom_ap = App.khom, 
                    maxa=m_phuong,
                    duongld=App.duongld,
                    xa_phuongld=App.phuongld,
                    khom_apld=App.khomld,
                    ma_nhom = cmbnhom.GetKeyValue(cmbnhom.SelectedIndex).ToString(),
                    ma_nghe = cmbnganh.GetKeyValue(cmbnganh.SelectedIndex).ToString(),
                    ngan_hang = this.txtNH.Text.Trim(),
                    e_mail = this.txtemail.Text.Trim(),
                    camket = Convert.ToInt16(this.spcamket.Text),
                    ma_km = cmbkm.GetKeyValue(cmbkm.SelectedIndex).ToString(),
                    ma_nvcs = cmbcbcs.SelectedIndex == -1 ? S_null : cmbcbcs.GetKeyValue(cmbcbcs.SelectedIndex).ToString(),
                    ma_nvkt = cmbcbkt.SelectedIndex == -1 ? S_null : cmbcbkt.GetKeyValue(cmbcbkt.SelectedIndex).ToString(),
                    dt_lh = this.txtdtlh.Text.Trim(),
                    so_119=so_119,
                    modem_seri = txtseri.Text.Trim(),
                    goi_th = cmbgoith.SelectedIndex == -1 ? S_null : this.cmbgoith.GetKeyValue(cmbgoith.SelectedIndex).ToString().Trim(),
                    id_goicuoc = cmbgoith.SelectedIndex == -1 ? S_null : App.id_goicuoc
                   
                };
                dstb.internets.Add(ds);


                internet_log dsl = new internet_log
                {
                    user_name = this.txtusr.Text.Trim(),
                    ten_dktb = this.txttentb.Text.Trim(),
                    ten_nsd = this.txttendb.Text.Trim(),
                    dia_chitb = this.txtdctb.Text.Trim(),
                    dc_tbld = this.txtdcld.Text.Trim(),
                    sohopdong = this.txtsohd.Text.Trim(),
                    ngay_hd = this.dngayhd.DateTime,
                    tuyen_tc = "",
                    maxa = m_phuong,
                    goi_cuoc = cmbgoicuoc.GetKeyValue(cmbgoicuoc.SelectedIndex).ToString(),
                    toc_do = cmbtocdo.GetKeyValue(cmbtocdo.SelectedIndex).ToString(),
                    so_dt = this.txtsdt.Text.Trim(),
                   // stb_serial = this.txtseri.Text.Trim(),
                    ma_dv = cmbdichvu.GetKeyValue(cmbdichvu.SelectedIndex).ToString(),
                    ht_ld = this.cmbhtld.Text.Trim().Substring(0, 1),
                    ma_huyen = App.ma_huyen,
                    socmnd = this.txtcmnd.Text.Trim(),
                    noi_cap = this.txtnoicap.Text.Trim(),
                    ngay_cap = this.dngaycap.DateTime,
                    ma_kh = this.txtmakh.Text,
                    kh_uutien = cmbkhuutien.GetKeyValue(cmbkhuutien.SelectedIndex).ToString().Trim(),
                    may_ngung = "M",
                    ht_tt=cmbhttt.Text.Trim(),
                    ngay_kn = this.dngaykn.DateTime,
                    note_ngay_kn = this.txtghichu.Text,                    
                    ms_thue = FunAndPro.ma_st(this.txtmst.Text.Trim()),                    
                    ngan_hang = this.txtNH.Text.Trim(),
                    ma_km = cmbkm.GetKeyValue(cmbkm.SelectedIndex).ToString(),
                    ma_nhom = cmbnhom.GetKeyValue(cmbnhom.SelectedIndex).ToString(),
                    ma_nghe = cmbnganh.GetKeyValue(cmbnganh.SelectedIndex).ToString(),
                    camket = Convert.ToInt16(this.spcamket.Text),
                    user_login = App.User_name,
                    ma_nvcs = cmbcbcs.SelectedIndex == -1 ? S_null : cmbcbcs.GetKeyValue(cmbcbcs.SelectedIndex).ToString(),
                    ma_nvkt = cmbcbkt.SelectedIndex == -1 ? S_null : cmbcbkt.GetKeyValue(cmbcbkt.SelectedIndex).ToString(),
                    thoi_gian=App.Current_d,
                    dt_lh = this.txtdtlh.Text.Trim(),
                    modem_seri = txtseri.Text.Trim(),
                    goi_th = cmbgoith.SelectedIndex == -1 ? S_null : this.cmbgoith.GetKeyValue(cmbgoith.SelectedIndex).ToString().Trim(),
                    id_goicuoc = cmbgoith.SelectedIndex == -1 ? S_null : App.id_goicuoc

                    
                };
                dstb.internet_logs.Add(dsl);
                dstb.SubmitChanges(OnSubmitCompleted,true);                
            }
            catch(Exception e)
            {
                MessageBox.Show(string.Format("Exception Failed: {0}",e));
            }
        }