Beispiel #1
0
        public PublicRegistrar InsertPublicRegistrar(PublicRegistrar ins)
        {
            PublicRegistrar ReturnObject = new PublicRegistrar();
            int             ModifiedBy   = (int)HttpContext.Current.Session["UserNo"];

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

            con.Open();

            SqlCommand     cmdI = con.CreateCommand();
            SqlTransaction trx  = con.BeginTransaction(CommonStrings.InsertTransaction);

            cmdI.Connection  = con;
            cmdI.Transaction = trx;

            try
            {
                cmdI.Parameters.Clear();
                cmdI.CommandText = CommonStrings.InsertPublicRegistrar;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@AnimalId", ins.AnimalId);
                cmdI.Parameters.AddWithValue("@RegistrationNumber", ins.RegistrationNumber);
                cmdI.Parameters.AddWithValue("@ModifiedDate", DateTime.Now);
                cmdI.Parameters.AddWithValue("@ModifiedBy", ModifiedBy);
                cmdI.Parameters.AddWithValue("@Removed", false);
                ins.PublicId = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null)
                {
                    trx.Rollback();
                }
            }
            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }

                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }

            return(ins);
        }
Beispiel #2
0
        public PublicRegistrar InsertPublicRegistrarSim(PublicRegistrar ins)
        {
            PublicRegistrar ReturnObject = new PublicRegistrar();

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();

            SqlCommand cmdI = con.CreateCommand();
            SqlTransaction trx = con.BeginTransaction(CommonStrings.InsertTransaction);

            cmdI.Connection = con;
            cmdI.Transaction = trx;

            try
            {
                cmdI.Parameters.Clear();
                cmdI.CommandText = CommonStrings.InsertPublicRegistrar;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@AnimalId", ins.AnimalId);
                cmdI.Parameters.AddWithValue("@RegistrationNumber", ins.RegistrationNumber);
                cmdI.Parameters.AddWithValue("@ModifiedDate", ins.ModifiedDate);
                cmdI.Parameters.AddWithValue("@ModifiedBy", ins.ModifiedBy);
                cmdI.Parameters.AddWithValue("@Removed", false);
                ins.PublicId = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null) trx.Rollback();
            }
            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }

                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }

            return ins;
        }
Beispiel #3
0
 public ActionResult _AddPublic(int id)
 {
     PublicRegistrar ins = new PublicRegistrar(id);
     return PartialView(ins);
 }
Beispiel #4
0
        public ActionResult _AddPublicRegistrar(PublicRegistrar ins)
        {
            ins = animalRep.InsertPublicRegistrar(ins);

            return RedirectToAction("Tag", new { id = ins.AnimalId });
        }
Beispiel #5
0
        public JsonResult AddToPublicRegistrar(int AnimalId, string RegNo, int UserKey, DateTime ModifiedDate)
        {
            PublicRegistrar pub = new PublicRegistrar();
            pub.AnimalId = AnimalId;
            pub.RegistrationNumber = RegNo;
            pub.ModifiedBy = UserKey;
            pub.ModifiedDate = ModifiedDate;

            pub = aniRep.InsertPublicRegistrarSim(pub);

            return Json(pub.PublicId, JsonRequestBehavior.AllowGet);
        }