예제 #1
0
 /// <summary>
 /// sinh ra chuoi dieu kien sau where
 /// </summary>
 /// <param name="list">danh sach ten column dung de so sanh</param>
 /// <param name="dongBoObject">value</param>
 /// <returns>chuoi dieu kien</returns>
 private string GenStringDieuKien(List<string> list, DongBoObject dongBoObject)
 {
     var result = "";
     if (list.IndexOf(ColumnKeyName.MA_DVI.ToString("G")) != -1)
         result += " " + ColumnKeyName.MA_DVI.ToString("G") + " = '" + dongBoObject.MA_DVI + "'";
     // cac thao tac voi bag luon can ton tai ma don vi
     if (list.IndexOf(ColumnKeyName.SO_ID.ToString("G")) != -1)
         result += " and " + ColumnKeyName.SO_ID.ToString("G") + " = " + dongBoObject.SO_ID;
     if (list.IndexOf(ColumnKeyName.MA.ToString("G")) != -1)
         result += " and " + ColumnKeyName.MA.ToString("G") + " = '" + dongBoObject.MA + "'";
     if (list.IndexOf(ColumnKeyName.SO_QD.ToString("G")) != -1)
         result += " and " + ColumnKeyName.SO_QD.ToString("G") + " = '" + dongBoObject.SO_QD + "'";
     if (list.IndexOf(ColumnKeyName.BT.ToString("G")) != -1)
         result += " and " + ColumnKeyName.BT.ToString("G") + " = " + dongBoObject.BT;
     if (list.IndexOf(ColumnKeyName.HANG.ToString("G")) != -1)
         result += " and " + ColumnKeyName.HANG.ToString("G") + " = " + dongBoObject.HANG;
     if (list.IndexOf(ColumnKeyName.MA_HT.ToString("G")) != -1)
         result += " and " + ColumnKeyName.MA_HT.ToString("G") + " = '" + dongBoObject.MA_HT + "'";
     if (list.IndexOf(ColumnKeyName.NAM.ToString("G")) != -1)
         result += " and " + ColumnKeyName.NAM.ToString("G") + " = " + dongBoObject.NAM;
     if (list.IndexOf(ColumnKeyName.DOT.ToString("G")) != -1)
         result += " and " + ColumnKeyName.DOT.ToString("G") + " = " + dongBoObject.DOT;
     if (list.IndexOf(ColumnKeyName.NHA.ToString("G")) != -1)
         result += " and " + ColumnKeyName.NHA.ToString("G") + " = '" + dongBoObject.NHA + "'";
     return result;
 }
예제 #2
0
 /// <summary>
 /// convert from data row to object 
 /// </summary>
 /// <param name="listColumnId"></param>
 /// <param name="dr"></param>
 /// <returns></returns>
 private DongBoObject GenObjectDongBo(List<string> listColumnId, DataRow dr)
 {
     var ob = new DongBoObject();
     if (listColumnId.IndexOf(ColumnKeyName.MA_DVI.ToString("G")) != -1)
         ob.MA_DVI = Convert.ToString(dr[listColumnId.IndexOf(ColumnKeyName.MA_DVI.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.SO_ID.ToString("G")) != -1)
         ob.SO_ID = Convert.ToInt64(dr[listColumnId.IndexOf(ColumnKeyName.SO_ID.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.MA.ToString("G")) != -1)
         ob.MA = Convert.ToString(dr[listColumnId.IndexOf(ColumnKeyName.MA.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.SO_QD.ToString("G")) != -1)
         ob.SO_QD = Convert.ToString(dr[listColumnId.IndexOf(ColumnKeyName.SO_QD.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.BT.ToString("G")) != -1)
         ob.BT = Convert.ToInt64(dr[listColumnId.IndexOf(ColumnKeyName.BT.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.HANG.ToString("G")) != -1)
         ob.HANG = Convert.ToInt64(dr[listColumnId.IndexOf(ColumnKeyName.HANG.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.MA_HT.ToString("G")) != -1)
         ob.MA_HT = Convert.ToString(dr[listColumnId.IndexOf(ColumnKeyName.MA_HT.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.NAM.ToString("G")) != -1)
         ob.NAM = Convert.ToInt64(dr[listColumnId.IndexOf(ColumnKeyName.NAM.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.DOT.ToString("G")) != -1)
         ob.DOT = Convert.ToInt64(dr[listColumnId.IndexOf(ColumnKeyName.DOT.ToString("G"))]);
     if (listColumnId.IndexOf(ColumnKeyName.NHA.ToString("G")) != -1)
         ob.NHA = Convert.ToString(dr[listColumnId.IndexOf(ColumnKeyName.NHA.ToString("G"))]);
     return ob;
 }