/// <summary>
 /// Xóa tbleAliasMapping
 /// </summary>
 /// <param name="pId"></param>
 public static void DeleteAliasMapping(int pId)
 {
     if (TblAliasMapping.FetchByID(pId) != null)
     {
         TblAliasMapping.Delete(pId);
     }
 }
        /// <summary>
        /// Insert vào tblAliasMapping in db
        /// </summary>
        /// <param name="pitems"></param>
        /// <returns></returns>
        public static string InsertAliasMapping(TblAliasMapping pitems)
        {
            int   i        = 0;
            Query _QueryRS = TblAliasMapping.CreateQuery();

            try
            {
                if (
                    !TblAliasMapping.FetchByParameter(TblAliasMapping.Columns.LocalAlias, Comparison.Equals,
                                                      pitems.LocalAlias).Read())
                {
                    pitems.IsNew = true;
                    pitems.Save(i);
                    return(_QueryRS.GetMax(TblAliasMapping.Columns.Id).ToString());
                }
                else
                {
                    return("-1");
                    //throw new Exception(string.Format("Name:{0} Đã tồn tại", pitems.IPAddress));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public void UpdateAliasMaping()
        {
            TblAliasMapping pitems;

            string localali = "", TestId = "";
            int    id_xn     = 0;
            var    dataTable = GrdAliasPara.DataSource as DataTable;

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                DataRow dr = dataTable.Rows[i];
                object  c  = dr[TblAliasMapping.Columns.Id];
                //Kiểm tra trạng thái của dòng:
                if ((dr.RowState == DataRowState.Modified) || (dr.RowState == DataRowState.Added))
                {
                    localali = dr[TblAliasMapping.Columns.LocalAlias].ToString();
                    TestId   = dr[TblAliasMapping.Columns.TestTypeId].ToString();
                    id_xn    = Convert.ToInt32(dr[TblAliasMapping.Columns.IdHisXn].ToString());

                    if ((localali == ""))
                    {
                        SetTextForWarning(MsgEror);
                        continue;
                    }
                }
                if (dr.RowState == DataRowState.Modified)
                {
                    pitems            = new TblAliasMapping(dr[TblAliasMapping.Columns.Id]);
                    pitems.LocalAlias = localali;
                    pitems.TestTypeId = Convert.ToInt32(TestId);
                    pitems.IdHisXn    = Convert.ToInt32(id_xn);
                    AliasMappingBusiness.UpdateAliasMapping(pitems);
                    SetTextForWarning(MsgUpdate);
                }
                else if (dr.RowState == DataRowState.Added)
                {
                    pitems            = new TblAliasMapping();
                    pitems.LocalAlias = localali;
                    pitems.TestTypeId = Convert.ToInt32(TestId);
                    pitems.IdHisXn    = Convert.ToInt32(id_xn);
                    string id = AliasMappingBusiness.InsertAliasMapping(pitems);
                    if (id == "-1")
                    {
                        //MessageBox.Show("Tên thông số  " + pitems.LocalAlias + "  đã tồn tại", "Thông báo:",
                        //                MessageBoxButtons.OK,
                        //                MessageBoxIcon.Error);
                        SetTextForWarning(MsgExits);
                        dr.Delete();
                    }
                    else
                    {
                        dr[TblAliasMapping.Columns.Id] = AliasMappingBusiness.InsertAliasMapping(pitems);
                        SetTextForWarning(MsgNew);
                    }
                }
            }
            dataTable.AcceptChanges();
        }
 /// <summary>
 /// Update tblAliasMaping
 /// </summary>
 /// <param name="pitems"></param>
 public static void UpdateAliasMapping(TblAliasMapping pitems)
 {
     try
     {
         if (TblAliasMapping.FetchByID(pitems.Id) != null)
         {
             pitems.IsNew = false;
             pitems.Save();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }