public SupplierType Insert(SupplierType ins)
        {
            //...Get User and Date Data...
            string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
            string EmployeeId   = Convert.ToString(HttpContext.Current.Session["Username"]);
            string strTrx       = "SupplierTypeIns_" + EmployeeId;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

            con.Open();

            //...Command Interface...
            SqlCommand     cmdI = con.CreateCommand();
            SqlTransaction trx;

            trx              = con.BeginTransaction(strTrx);
            cmdI.Connection  = con;
            cmdI.Transaction = trx;

            try
            {
                //...Insert Record...
                cmdI.CommandText = StoredProcedures.SupplierTypeInsert;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                //cmdI.Parameters.AddWithValue("@SupplierTypeID", ins.SupplierTypeID);
                cmdI.Parameters.AddWithValue("@SupplierType", ins.SupplierTypes);
                cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);
                cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate);
                cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId);
                cmdI.Parameters.AddWithValue("@Removed", ins.Removed);

                //...Return new ID
                ins.SupplierTypeID = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null)
                {
                    trx.Rollback();
                }
            }
            finally
            {
                //Check for close and respond accordingly
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
                //Clean up
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }
            return(ins);
        }
        public SupplierType Update(SupplierType ins)
        {
            //...Get User and Date Data...
            string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
            string EmployeeId   = Convert.ToString(HttpContext.Current.Session["Username"]);

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

            con.Open();
            SqlCommand cmdI = con.CreateCommand();

            cmdI.Connection = con;

            //...Update Record...
            cmdI.Parameters.Clear();
            cmdI.CommandText = StoredProcedures.SupplierTypeUpdate;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@SupplierTypeID", ins.SupplierTypeID);
            cmdI.Parameters.AddWithValue("@SupplierType", ins.SupplierTypes);
            cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);
            cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate);
            cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId);


            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();

            return(ins);
        }
        public ActionResult _InsertSupplierTypes(SupplierType ins)
        {
            //...Insert Object
            SupplierType ins2 = SupplierTRep.Insert(ins);

            //...Repopulate Grid...
            return View(new GridModel(SupplierTRep.GetAllSupplierType()));
        }
        public List <SupplierType> GetAllSupplierType()
        {
            //...Create New Instance of Object...
            List <SupplierType> list = new List <SupplierType>();
            SupplierType        ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();
            SqlCommand         cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM l_SupplierType", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new SupplierType();
                    ins.SupplierTypeID = Convert.ToInt32(drI["SupplierTypeID"]);
                    ins.SupplierTypes  = Convert.ToString(drI["SupplierType"]);
                    ins.CompanyID      = Convert.ToInt32(drI["CompanyID"]);
                    ins.ModifiedDate   = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.ModifiedBy     = Convert.ToString(drI["ModifiedBy"]);
                    ins.Removed        = Convert.ToBoolean(drI["Removed"]);
                    list.Add(ins);
                }
            }

            //...Close Connections...
            drI.Close();
            con.Close();


            //...Return...
            return(list);
        }
        public List<SupplierType> GetAllSupplierType()
        {
            //...Create New Instance of Object...
            List<SupplierType> list = new List<SupplierType>();
            SupplierType ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM l_SupplierType", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new SupplierType();
                    ins.SupplierTypeID = Convert.ToInt32(drI["SupplierTypeID"]);
                    ins.SupplierTypes = Convert.ToString(drI["SupplierType"]);
                    ins.CompanyID = Convert.ToInt32(drI["CompanyID"]);
                    ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.ModifiedBy = Convert.ToString(drI["ModifiedBy"]);
                    ins.Removed = Convert.ToBoolean(drI["Removed"]);
                    list.Add(ins);
                }
            }

            //...Close Connections...
            drI.Close();
            con.Close();

            //...Return...
            return list;
        }
        public SupplierType Insert(SupplierType ins)
        {
            //...Get User and Date Data...
             string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
              string EmployeeId = Convert.ToString(HttpContext.Current.Session["Username"]);
             string strTrx = "SupplierTypeIns_" + EmployeeId;

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

            //...Command Interface...
            SqlCommand cmdI = con.CreateCommand();
            SqlTransaction trx;
             trx = con.BeginTransaction(strTrx);
            cmdI.Connection = con;
            cmdI.Transaction = trx;

            try
            {
                //...Insert Record...
                cmdI.CommandText = StoredProcedures.SupplierTypeInsert;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                //cmdI.Parameters.AddWithValue("@SupplierTypeID", ins.SupplierTypeID);
                cmdI.Parameters.AddWithValue("@SupplierType", ins.SupplierTypes);
                cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);
                cmdI.Parameters.AddWithValue("@ModifiedDate",ModifiedDate);
               cmdI.Parameters.AddWithValue("@ModifiedBy",EmployeeId);
                cmdI.Parameters.AddWithValue("@Removed", ins.Removed);

                //...Return new ID
                ins.SupplierTypeID = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null) trx.Rollback();
            }
            finally
            {
                //Check for close and respond accordingly
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
                //Clean up
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }
            return ins;
        }
        public SupplierType Update(SupplierType ins)
        {
            //...Get User and Date Data...
            string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
             string EmployeeId = Convert.ToString(HttpContext.Current.Session["Username"]);

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            //...Update Record...
            cmdI.Parameters.Clear();
            cmdI.CommandText = StoredProcedures.SupplierTypeUpdate;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@SupplierTypeID", ins.SupplierTypeID);
            cmdI.Parameters.AddWithValue("@SupplierType", ins.SupplierTypes);
            cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);
            cmdI.Parameters.AddWithValue("@ModifiedDate",ModifiedDate);
               cmdI.Parameters.AddWithValue("@ModifiedBy",EmployeeId);

            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();

            return ins;
        }
        public ActionResult _UpdateSupplierTypes(SupplierType ins)
        {
            //...Update Object
            SupplierType ins2 = SupplierTRep.Update(ins);

            //...Repopulate Grid...
            return View(new GridModel(SupplierTRep.GetAllSupplierType()));
        }