Click here to Skip to main content
15,900,254 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: wsdl Pin
Laxman Auti28-Jun-10 20:44
Laxman Auti28-Jun-10 20:44 
GeneralRe: wsdl Pin
gerom7728-Jun-10 21:37
gerom7728-Jun-10 21:37 
AnswerRe: wsdl Pin
Laxman Auti28-Jun-10 21:58
Laxman Auti28-Jun-10 21:58 
QuestionError occoured while downloading ZIP file Pin
koolprasad200328-Jun-10 19:13
professionalkoolprasad200328-Jun-10 19:13 
AnswerRe: Error occoured while downloading ZIP file Pin
Sandeep Mewara28-Jun-10 19:42
mveSandeep Mewara28-Jun-10 19:42 
QuestionArabic Conversion Pin
SreejithAchutan28-Jun-10 18:58
SreejithAchutan28-Jun-10 18:58 
AnswerRe: Arabic Conversion Pin
Sandeep Mewara28-Jun-10 19:34
mveSandeep Mewara28-Jun-10 19:34 
QuestionMVC project and storeprocedured(Please help) [modified] Pin
future383928-Jun-10 16:58
future383928-Jun-10 16:58 
hi every1,

I am developing code in MVC project. I craeted a class in Model and define related function. the problem is I don't know what I have to write in Controller part.

this is my program

its my class:item.cs

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace MvcApplication1.Models.Repository.DTO
{
    public class Item
    {
        //definition of class's fileds
        public int _id;
        public int _code;
        public string _description;
        public string _creator;
        public DateTime _created;


        //definition of properties
        public int Id
        {
            set 
            {
                _id = value;
                if (value < 0)
                    throw new ArgumentException(string.Format("Id should be greater than 0 !"));
            }
            get { return _id; }
        }
        public int Code
        {
            set { _code = value; }
            get { return _code; }
        }
        public string Description
        {
            set { _description = value; }
            get { return _description; }
        }
        public string Creator
        {
            set { _creator = value; }
            get { return _creator; }
        }
        public DateTime Created
        {
            set { _created = value; }
            get { return _created; }
        }

        //definiton of constructor
        public Item(int id, int code, string description, string creator, DateTime created)
        {
            this._id = id;
            this._code = code;
            this._description = description;
            this._creator = creator;
            this._created = created;
        }
    }
}





then in Model part in another class I write:

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using MvcApplication1.Models.Repository.DTO;

namespace MvcApplication1.Repository
{
    public class ItemRepository
    {
        //definition of fields
        private const string datasource =
            "Data Source= Dell\\SQLEXPRESS;Initial Catalog=DB_Furniture.mdf;Integrated Security=True;User Instance=True";

        private SqlConnection _connection;
        private SqlCommand _sqlcommand;
        private SqlDataReader _datareader;
        //definition of constructor
        public ItemRepository()
        {           
            // instantiate the connection
            _connection = new SqlConnection(datasource);     
        }
        //definition of insert method
        public void Insert(string code, string description, DateTime created, string creator)
        {
            //definition of SQl SP parameters
            _sqlcommand = new SqlCommand("Ins_item",_connection);
            _sqlcommand.CommandType = CommandType.StoredProcedure;
            _sqlcommand.Parameters.AddWithValue("@Code", code);
            _sqlcommand.Parameters.AddWithValue("@Description", description);
            _sqlcommand.Parameters.AddWithValue("@Created", created);
            _sqlcommand.Parameters.AddWithValue("@Creator", creator);
            _datareader = _sqlcommand.ExecuteReader();

        }
    }
}

the problem is here. I don't know what should I write in Controller part

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MvcApplication1.Models.Repository.DTO;
using MvcApplication1.Models.Repository;
using MvcApplication1.Repository;
namespace MvcApplication1.Controllers
{
    public class FurnitureController : Controller
    {
        //
        // GET: /Furniture/

        public ActionResult Index()
        {
            return View();
        }

        //Get: /Furniture/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: /Furniture/Create
        //  [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Craete(Item item)
        {
            try
            {
                ItemRepository ItemRep = new ItemRepository();
??????????????????????????????????????????????????????????????????????????????????
?
 ??
            }
            catch
            {
            }
        }

    } 
}

Plaese help me what I have to write here. give me some code.
thxxxxxxxx

modified on Tuesday, June 29, 2010 11:19 AM

AnswerRe: MVC project and storeprocedured(Please help) Pin
Sandeep Mewara28-Jun-10 19:33
mveSandeep Mewara28-Jun-10 19:33 
GeneralRe: MVC project and storeprocedured(Please help) Pin
future383929-Jun-10 5:30
future383929-Jun-10 5:30 
GeneralRe: MVC project and storeprocedured(Please help) Pin
future383929-Jun-10 14:31
future383929-Jun-10 14:31 
QuestionFormatting currency Pin
Civic0628-Jun-10 12:25
Civic0628-Jun-10 12:25 
AnswerRe: Formatting currency Pin
Sandeep Mewara28-Jun-10 19:32
mveSandeep Mewara28-Jun-10 19:32 
QuestionRad ListBox Pin
indian14328-Jun-10 9:41
indian14328-Jun-10 9:41 
AnswerRe: Rad ListBox Pin
netJP12L28-Jun-10 11:25
netJP12L28-Jun-10 11:25 
Questionfolder name in iis 7 Pin
netJP12L28-Jun-10 9:35
netJP12L28-Jun-10 9:35 
GeneralRe: folder name in iis 7 Pin
Paladin200028-Jun-10 10:58
Paladin200028-Jun-10 10:58 
GeneralRe: folder name in iis 7 Pin
netJP12L28-Jun-10 11:22
netJP12L28-Jun-10 11:22 
GeneralRe: folder name in iis 7 Pin
Laxman Auti28-Jun-10 20:48
Laxman Auti28-Jun-10 20:48 
QuestionSession data takes two button clicks to work? Pin
Jacob Dixon28-Jun-10 9:19
Jacob Dixon28-Jun-10 9:19 
AnswerRe: Session data takes two button clicks to work? Pin
Ennis Ray Lynch, Jr.28-Jun-10 9:31
Ennis Ray Lynch, Jr.28-Jun-10 9:31 
GeneralRe: Session data takes two button clicks to work? Pin
Jacob Dixon28-Jun-10 9:33
Jacob Dixon28-Jun-10 9:33 
GeneralRe: Session data takes two button clicks to work? Pin
Jacob Dixon28-Jun-10 9:45
Jacob Dixon28-Jun-10 9:45 
GeneralRe: Session data takes two button clicks to work? Pin
Ennis Ray Lynch, Jr.28-Jun-10 9:55
Ennis Ray Lynch, Jr.28-Jun-10 9:55 
GeneralRe: Session data takes two button clicks to work? Pin
Jacob Dixon28-Jun-10 10:15
Jacob Dixon28-Jun-10 10:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.