예제 #1
0
 public ActionResult CommentsEdit(FormCollection form)
 {
     if (!string.IsNullOrEmpty(Session["username"] as string))
     {
         try
         {
             List <SalesComments> lst = new List <SalesComments>();
             for (int i = 1; i <= 2; i++)
             {
                 SalesComments obj = new SalesComments();
                 obj.comment   = form["comment" + i];
                 obj.sector    = form["sector" + i];
                 obj.commentid = i + 2;
                 lst.Add(obj);
             }
             Salesdata sd = new Salesdata();
             foreach (SalesComments obj in lst)
             {
                 sd.UpdateCommentSales(obj);
             }
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             return(View("Error", ex));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
예제 #2
0
        public List <SalesComments> GetSalesComments()
        {
            List <SalesComments> lst = new List <SalesComments>();
            DataSet data             = DBConnection.GetData("getSalesComments");

            foreach (DataRow row in data.Tables[0].Rows)
            {
                SalesComments Obj = new SalesComments();
                Obj.commentid = Convert.ToInt32(row["commentid"].ToString());
                Obj.sector    = !String.IsNullOrEmpty(row["sector"].ToString()) ? row["sector"].ToString() : string.Empty;
                Obj.comment   = !String.IsNullOrEmpty(row["comments"].ToString()) ? row["comments"].ToString() : string.Empty;
                lst.Add(Obj);
            }
            return(lst);
        }
예제 #3
0
 public void UpdateCommentSales(SalesComments obj)
 {
     using (SqlConnection con = new SqlConnection(DBConnection.GetConnectionString()))
     {
         using (SqlCommand cmd = new SqlCommand("UpdatesalesComment", con))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@commentid", obj.commentid);
             cmd.Parameters.AddWithValue("@comments", obj.comment);
             cmd.Parameters.AddWithValue("@sector", obj.sector);
             con.Open();
             cmd.ExecuteNonQuery();
         }
     }
 }