Ejemplo n.º 1
0
 private void txtMadv_LostFocus(object sender, RoutedEventArgs e)
 {
     if (isEdit && txtMadv.Text != "" && txtMadv.Text != null)
     {
         DataTable otblDV = new MTSQLServer().wRead(String.Format("SELECT TOP 1 Makh,Tenkh,Dienthoai,Diachi FROM DM_KHACHHANG WHERE makh='{0}'", txtSoxe.Text), null, false);
         if (otblDV != null && otblDV.Rows.Count > 0)
         {
             foreach (DataRow vR in otblDV.Rows)
             {
                 txtMadv.Text      = vR["Makh"].ToString();
                 txtTendonvi.Text  = vR["Tenkh"].ToString();
                 txtDienthoai.Text = vR["Dienthoai"].ToString();
                 txtDiachi.Text    = vR["Diachi"].ToString();
                 return;
             }
         }
         else
         {
             dlg_ChonDM oDM = new dlg_ChonDM("DV");
             oDM.ShowDialog();
             DataRowView vRw = oDM.pRowChon;
             if (vRw != null && vRw.Row.ItemArray.Length > 0)
             {
                 txtMadv.Text      = vRw.Row.ItemArray.GetValue(1).ToString().ToUpper();
                 txtTendonvi.Text  = vRw.Row.ItemArray.GetValue(2).ToString().ToUpper();
                 txtDienthoai.Text = vRw.Row.ItemArray.GetValue(3).ToString().ToUpper();
                 txtDiachi.Text    = vRw.Row.ItemArray.GetValue(4).ToString().ToUpper();
             }
         }
     }
     if (txtMadv.Text == "" && txtDienthoai.Text == "")
     {
         txtTendonvi.Text = ""; txtDiachi.Text = "";
     }
 }
Ejemplo n.º 2
0
        private void txtMaLD_LostFocus_1(object sender, RoutedEventArgs e)
        {
            if (isEdit && txtMaLD.Text != "" && txtMaLD.Text != null)
            {
                String mLydo = new MTSQLServer().getNameByValue("SELECT Lydo FROM DM_LYDO", "Mald", txtMaLD.Text.Trim(), "Lydo");
                if (mLydo == "" || mLydo == null)
                {
                    dlg_ChonDM oDM = new dlg_ChonDM("LYDO");
                    oDM.ShowDialog();
                    txtMaLD.Text = oDM.pMaso;
                    txtLD.Text   = oDM.pGiaTriChon;
                    TKNo         = oDM.pTKNo;
                    TKCo         = oDM.pTKCo;
                }
                else
                {
                    String    mSql    = String.Format("SELECT Mald, Lydo, TKNo, TKCo FROM DM_LYDO with(nolock) where Mald='{0}'", txtMaLD.Text.Trim().ToUpper());
                    DataTable oTblSrc = new MTSQLServer().wRead(mSql, null, false);

                    if (oTblSrc.Rows.Count == 1)
                    {
                        txtLD.Text = mLydo;
                        TKNo       = oTblSrc.Rows[0].ItemArray[2].ToString();
                        TKCo       = oTblSrc.Rows[0].ItemArray[3].ToString();
                    }
                }
            }
            if (txtMaLD.Text == "")
            {
                txtLD.Text = "";
            }
        }
Ejemplo n.º 3
0
 private void txtSoxe_LostFocus(object sender, RoutedEventArgs e)
 {
     if (isEdit && txtSoxe.Text != null && txtSoxe.Text != "")
     {
         DataTable otblXe = new MTSQLServer().wRead(String.Format("SELECT TOP 1 Soxe,Loaixe,Taixe,Dienthoai FROM DM_XE  WHERE Soxe='{0}'", txtSoxe.Text), null, false);
         if (otblXe != null && otblXe.Rows.Count > 0)
         {
             foreach (DataRow vR in otblXe.Rows)
             {
                 txtSoxe.Text        = vR["Soxe"].ToString();
                 txtLoaixe.Text      = vR["Loaixe"].ToString();
                 txtTaixe.Text       = vR["Taixe"].ToString();
                 txtDienthoaiXe.Text = vR["Dienthoai"].ToString();
                 return;
             }
         }
         else
         {
             dlg_ChonDM oDM = new dlg_ChonDM("XE");
             oDM.ShowDialog();
             DataRowView vRw = oDM.pRowChon;
             if (vRw != null && vRw.Row.ItemArray.Length > 0)
             {
                 txtSoxe.Text        = vRw.Row.ItemArray.GetValue(1).ToString().ToUpper();
                 txtLoaixe.Text      = vRw.Row.ItemArray.GetValue(2).ToString().ToUpper();
                 txtTaixe.Text       = vRw.Row.ItemArray.GetValue(3).ToString().ToUpper();
                 txtDienthoaiXe.Text = vRw.Row.ItemArray.GetValue(4).ToString().ToUpper();
             }
         }
     }
     if (txtSoxe.Text == "" && txtDienthoaiXe.Text == "")
     {
         txtLoaixe.Text = ""; txtTaixe.Text = "";
     }
 }
Ejemplo n.º 4
0
        private void txtMaDT_LostFocus_1(object sender, RoutedEventArgs e)
        {
            if (isEdit && txtMaDT.Text != "" && txtMaDT.Text != null)
            {
                String mTENKH = new MTSQLServer().getNameByValue("SELECT Tenkh FROM DM_KHACHHANG", "Makh", txtMaDT.Text.Trim(), "Tenkh");
                if (mTENKH == "" || mTENKH == null)
                {
                    dlg_ChonDM oDM = new dlg_ChonDM("DV");
                    oDM.ShowDialog();
                    txtMaDT.Text        = oDM.pMaso;
                    txtTenDoiTuong.Text = oDM.pGiaTriChon;
                    txtHoTen.Text       = oDM.pGiaTriChon;
                    txtDiaChi.Text      = oDM.pDiaChi;
                }
                else
                {
                    txtTenDoiTuong.Text = mTENKH;
                    txtHoTen.Text       = mTENKH;
                    txtDiaChi.Text      = new MTSQLServer().getNameByValue("SELECT Diachi FROM DM_KHACHHANG", "Makh", txtMaDT.Text.Trim(), "Diachi");
                }

                txtDiaChi.Focus();
            }
            if (txtMaDT.Text == "")
            {
                txtTenDoiTuong.Text = "";
            }
        }
Ejemplo n.º 5
0
 private void txtMald_LostFocus(object sender, RoutedEventArgs e)
 {
     if (isEdit && txtMald.Text != "" && txtMald.Text != null)
     {
         String mLydo = new MTSQLServer().getNameByValue("SELECT Lydo FROM DM_LYDO", "Mald", txtMald.Text.Trim(), "Lydo");
         if (mLydo == "" || mLydo == null)
         {
             dlg_ChonDM oDM = new dlg_ChonDM("LYDO");
             oDM.ShowDialog();
             txtMald.Text = oDM.pMaso;
             txtLydo.Text = oDM.pGiaTriChon;
             TKNo         = oDM.pTKNo;
             TKCo         = oDM.pTKCo;
             txtTKNo.Text = oDM.pTKNo;
             txtTKCo.Text = oDM.pTKCo;
         }
         else
         {
             txtLydo.Text = mLydo;
         }
     }
     if (txtMald.Text == "")
     {
         txtLydo.Text = "";
     }
 }
Ejemplo n.º 6
0
 private void txtManv_LostFocus_1(object sender, RoutedEventArgs e)
 {
     if (isEdit && txtManv.Text != "" && txtMaLD.Text != null)
     {
         String mManv = new MTSQLServer().getNameByValue("SELECT Manv FROM DM_NHANVIEN", "Manv", txtManv.Text.Trim(), "Tennv");
         if (mManv == "" || mManv == null)
         {
             dlg_ChonDM oDM = new dlg_ChonDM("NHANVIEN");
             oDM.ShowDialog();
             txtManv.Text  = oDM.pMaso;
             txtTennv.Text = oDM.pGiaTriChon;
         }
         else
         {
             txtTennv.Text = mManv;
         }
     }
     if (txtManv.Text == "")
     {
         txtTennv.Text = "";
     }
 }
Ejemplo n.º 7
0
 private void txtMadv_LostFocus(object sender, RoutedEventArgs e)
 {
     if (isEdit && txtMadv.Text != "" && txtMadv.Text != null)
     {
         String mTENKH = new MTSQLServer().getNameByValue("SELECT Tenkh FROM DM_KHACHHANG", "Makh", txtMadv.Text.Trim(), "Tenkh");
         if (mTENKH == "" || mTENKH == null)
         {
             dlg_ChonDM oDM = new dlg_ChonDM("DV");
             oDM.ShowDialog();
             txtMadv.Text     = oDM.pMaso;
             txtTendonvi.Text = oDM.pGiaTriChon;
         }
         else
         {
             txtTendonvi.Text = mTENKH;
         }
     }
     if (txtMadv.Text == "")
     {
         txtTendonvi.Text = "";
     }
 }
Ejemplo n.º 8
0
 private void txtMakho_LostFocus(object sender, RoutedEventArgs e)
 {
     if (isEdit && isModified && txtMakho.Text != "" && txtMakho.Text != null)
     {
         String mTenKho = new MTSQLServer().getNameByValue("SELECT Tenkho FROM DM_KHO", "Makho", txtMakho.Text.Trim(), "Tenkho");
         if (mTenKho == "" || mTenKho == null)
         {
             dlg_ChonDM oDM = new dlg_ChonDM("KHO");
             oDM.ShowDialog();
             txtMakho.Text  = oDM.pMaso;
             txtTenkho.Text = oDM.pGiaTriChon;
         }
         else
         {
             txtTenkho.Text = mTenKho;
         }
     }
     if (txtMakho.Text == "")
     {
         txtTenkho.Text = "";
     }
 }