Saturday, May 24, 2014

How To Find The port No. Of Xampp

To Get The Port No Of Xampp:


Follow the steps:

Xampp>Apache>Conf>httpd.conf>[open with notepad and look for Listen, e.g.'Listen 6060' ]

(e.g. Brouse localhost:6060)


 

Tuesday, February 11, 2014

How To Create Dynamic Dropdownlist in MVC 5 EF 6

*** Just Follow the Bold Lines...


Table:

create table tblInsPlans
(
    InsID        Numeric(11),
    InsDueDate     Datetime,
    InsSeq         Numeric(3),
    InsAmt         Numeric(11,2),
    PaidAmt        Numeric(11,2),
    HeadID         Numeric(3),--FK
    Remarks     Varchar(100),
    InsertedBy     VARCHAR(15) null,
    InsertedOn     DATETime  null,
    UpdatedBy      VARCHAR(15) null,
    UpdatedOn      DATETime  null,
    IsActive       bit not null DEFAULT(0),
    IsDeleted     bit not null DEFAULT(0),

    primary    key(InsID),
    FOREIGN KEY(HeadID) REFERENCES tblColHeads(HeadID)
);

 

Model:

 public class tblInsPlan
    {

        [Required, Key, DatabaseGenerated(DatabaseGeneratedOption.None)]

        [DisplayName("Install ID")]
        public decimal InsID { get; set; }
         [DisplayName("Install Due Date")]
        public DateTime? InsDueDate { get; set; }
         [DisplayName("Install Sequence")]
         public decimal InsSeq { get; set; }
         [DisplayName("Install Amount")]
         public decimal InsAmt { get; set; }
         [DisplayName("Paid Amount")]
         public decimal PaidAmt { get; set; }
         [DisplayName("Head ID")]
         public decimal HeadID { get; set; }
        [DisplayName("Remarks")]
         public decimal Remarks { get; set; }
        [DisplayName("Inserted By")]
        public string InsertedBy { get; set; }
        [DisplayName("Inserted On")]
        public DateTime? InsertedOn { get; set; }
        [DisplayName("Updated By")]
        public string UpdatedBy { get; set; }
        [DisplayName("Updated On")]
        public DateTime? UpdatedOn { get; set; }
        [DisplayName("Is Active")]
        public bool IsActive { get; set; }
        [DisplayName("Is Deleted")]
        public bool IsDeleted { get; set; }

        public virtual tblColHead tblColHead { get; set; }

    }

Controller:

 public class InsPlanController : Controller
    {
        private BLRSDBEntities db = new BLRSDBEntities();

        // GET: /InsPlan/
        public ActionResult Index()
        {

            var tblinsplans = db.tblInsPlans.Include(t => t.tblColHead);

            return View(tblinsplans.ToList());

        }

        // GET: /InsPlan/Details/5
        public ActionResult Details(decimal id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            tblInsPlan tblinsplan = db.tblInsPlans.Find(id);
            if (tblinsplan == null)
            {
                return HttpNotFound();
            }
            return View(tblinsplan);
        }

        // GET: /InsPlan/Create
        public ActionResult Create()
        {

            ViewBag.HeadID = new SelectList(db.tblColHeads, "HeadID", "Title");

            return View();
        }

        // POST: /InsPlan/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include="InsID,InsDueDate,InsSeq,InsAmt,PaidAmt,HeadID,Remarks,InsertedBy,InsertedOn,UpdatedBy,UpdatedOn,IsActive,IsDeleted")] tblInsPlan tblinsplan)
        {
            if (ModelState.IsValid)
            {
              //  tblinsplan.InsID = Common.GetMaxIDInt("tblInsPlans", "InsID");
             //   tblinsplan.InsertedBy = "Mn";
             //   tblinsplan.InsertedOn = System.DateTime.Now;
                db.tblInsPlans.Add(tblinsplan);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.HeadID = new SelectList(db.tblColHeads, "HeadID", "Title", tblinsplan.HeadID);

            return View(tblinsplan);
        }

        // GET: /InsPlan/Edit/5
        public ActionResult Edit(decimal id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            tblInsPlan tblinsplan = db.tblInsPlans.Find(id);
            if (tblinsplan == null)
            {
                return HttpNotFound();
            }

            ViewBag.HeadID = new SelectList(db.tblColHeads, "HeadID", "Title", tblinsplan.HeadID);

            return View(tblinsplan);

        }

        // POST: /InsPlan/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include="InsID,InsDueDate,InsSeq,InsAmt,PaidAmt,HeadID,Remarks,InsertedBy,InsertedOn,UpdatedBy,UpdatedOn,IsActive,IsDeleted")] tblInsPlan tblinsplan)
        {
            if (ModelState.IsValid)
            {
            //    tblinsplan.UpdatedBy = "Mamun";
             //   tblinsplan.UpdatedOn = System.DateTime.Now;
                db.Entry(tblinsplan).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.HeadID = new SelectList(db.tblColHeads, "HeadID", "Title", tblinsplan.HeadID);

            return View(tblinsplan);
        }

        // GET: /InsPlan/Delete/5
        public ActionResult Delete(decimal id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            tblInsPlan tblinsplan = db.tblInsPlans.Find(id);
            if (tblinsplan == null)
            {
                return HttpNotFound();
            }
            return View(tblinsplan);
        }

        // POST: /InsPlan/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(decimal id)
        {
            tblInsPlan tblinsplan = db.tblInsPlans.Find(id);
            db.tblInsPlans.Remove(tblinsplan);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }

    }

How To Create Static DropdownList in MVC 5

@{
   List<SelectListItem> listItems= new List<SelectListItem>();
   listItems.Add(new SelectListItem
        {
          Text = "Exemplo1",
          Value = "0"
        });
   listItems.Add(new SelectListItem
        {
            Text = "Exemplo2",
            Value = "1",
            Selected = true
        });
   listItems.Add(new SelectListItem
        {
            Text = "Exemplo3",
            Value = "2"
        });
}

@Html.DropDownListFor(model => model.tipo, listItems, "-- Select Status --")
 
 
 
Another Example:
CREATE 
 
 <div class="form-group">
                @Html.LabelFor(model => model.RattioType, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                @{
                 List<SelectListItem> listItems = new List<SelectListItem>();
                
                 listItems.Add(new SelectListItem
                 {
                 Text = "Percent",
                 Value = "0",
                  Selected = true
                  });
                 
                  listItems.Add(new SelectListItem
                {
                 Text = "Fixed",
                 Value = "1"
                
                }); 
       
                    }

                    @Html.DropDownList("RattioType", listItems, "Percent")
                    @Html.ValidationMessageFor(model => model.RattioType)
                </div>
            </div> 
 
EDIT
 <div class="form-group">
                @Html.LabelFor(model => model.RattioType, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @{
                     List<SelectListItem> listItems = new List<SelectListItem>();

                      listItems.Add(new SelectListItem
                    {
                      Text = "Percent",
                      Value = "0",
                      Selected = true
                    });

                  listItems.Add(new SelectListItem
                 {
                 Text = "Fixed",
                 Value = "1"

                 });

                    }

                    @Html.DropDownList("RattioType", listItems)
                    @Html.ValidationMessageFor(model => model.RattioType)
                </div>
            </div> 

Sunday, February 9, 2014

ANDROID APPLICATIONS  

How to Call a Dotnet Web Service using Android App.

package com.cineplexbd.movieticket;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;

public class MnWebService extends Activity {
     TextView result;
     final String SOAP_ACTION = "http://tempuri.org/HelloWorld";
     final String METHOD_NAME = "HelloWorld";
     final String NAMESPACE = "http://tempuri.org/";
     final String URL = "http://192.168.10.13/WebService/TestWebService.asmx";
//Or //use any 1 String URL
//final String URL = "http://mmm.com/SampleService.svc?wsdl";

     Object response;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mn_web_service);
         result = new TextView(this);

         setContentView(result);
         new backMethod().execute();
    }
    public class backMethod extends AsyncTask<String, Object, Object > {

       
         private final ProgressDialog dialog = new ProgressDialog(MnWebService.this);   
                                    
                                        @Override
                                        protected void onPreExecute() {
                                    
                                                        this.dialog.setMessage("Checking...");             
                                                         this.dialog.show(); 
                                        }

                                        @Override
                                        protected void onCancelled(Object result) {
                                                    
                                                        super.onCancelled(result);
                                        }

                                        @Override
                                        protected void onPostExecute(Object result) {
                                       //Here All your UI part is Done
                                    
                                                        if (result != null) {
                                                                        String myOutput=result.toString();
                                                                        MnWebService.this.result.setText(myOutput);
                                                                        setContentView(MnWebService.this.result);
                                                    
                                                        } else {
                                                                        Toast.makeText(getApplicationContext(),
                                                               "Result Found is ==  " + result + "", Toast.LENGTH_LONG)
                                                                                                        .show();
                                                        }
                                                        super.onPostExecute(result);
                                                        if (this.dialog.isShowing()) {

                                                                        this.dialog.dismiss();
                                                        }
                                                        super.onPostExecute(result);
                                        }

                                    
                                        @Override
                                        protected Object doInBackground(String... params) {
                                                                                    
                                        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

                                       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                                                                                        SoapEnvelope.VER11);
                                                        envelope.dotNet = true;
                                                        envelope.setOutputSoapObject(request);
                                                        try {

                                                                        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

                                                                        androidHttpTransport.call(SOAP_ACTION, envelope);
                                                                    
                                                                        response = (SoapPrimitive) envelope.getResponse();
                                                                                     //here SoapPrimitive is an important part                                                                                             
                                                        } catch (Exception e) {
                                                                        e.printStackTrace();
                                                        }
                                                        return response;
                                        }
                        }
   
}


To  Download Ksoap2, Click here

 

ASP.NET MVC 5

# Getting Started...
#Adding a Controller...
#Adding a View...
#Adding a Model...
#Creating a Connection String and  Working with SQL Server 2008 and uploading an Image using MVC 5
Table:

Find  the <connectionStrings>  element:






<connectionStrings>
    <add name="BLRSDBEntities"
     connectionString="Server=192.168.10.15\SS8;Database=BLRSDB;User Id=sa;Password=1234; providerName="System.Data.SqlClient" />

    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-BLRS-20140119112437.mdf;Initial Catalog=aspnet-BLRS-20140119112437;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

create a class at model:
 public class tblCompanye
    {
        [Required, Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
        [DisplayName("Company ID")]
         public decimal CompID {get;set;}
        [DisplayName("Company Code")]
         public string CompCode    {get;set;}
        [DisplayName("Company Name")]
         public string CompName    {get;set;}
        [DisplayName("Company Address")]
         public string CompAddr {get;set;}
        [DisplayName("Phone No")]
         public string PhoneNo        {get;set;}
        [DisplayName("Mobile No")]
         public string MobileNo    {get;set;}
        [DisplayName("Fax")]
         public string Fax    {get;set;}
        [DisplayName("Email")]
         public string Email    {get;set;}
        [DisplayName("WEB URL")]
         public string WebURL        {get;set;}
        [DisplayName("Company Logo")]
         public byte[] CompLogo    {get;set;}
        [DisplayName("Reference ID")]
         public decimal RefID        {get;set;}
        [DisplayName("Inserted By")]
         public string InsertedBy  {get;set;}
        [DisplayName("Inserted On")]
         public DateTime? InsertedOn  {get;set;}
        [DisplayName("Updated By")]
         public string UpdatedBy   {get;set;}
        [DisplayName("Updated On")]
         public DateTime?  UpdatedOn  {get;set;}
        [DisplayName("Is Active")]
         public bool IsActive { get; set; }
      
    }
}

 public class BLRSDBEntities :DbContext{
 public System.Data.Entity.DbSet<BLRS.Models.tblCompanye> tblCompanyes { get; set; }
}

The name of the connection string must match the name of the DbContext class.

Create  a Controller:
  public class CompanyController : Controller
    {
        private BLRSDBEntities db = new BLRSDBEntities();

        // GET: /Company/
        public ActionResult Index()
        {
            return View(db.tblCompanyes.ToList());
        }
        public ActionResult MyImage(int id, int img)
        {
            ViewBag.Pic = img;
            tblCompanye insp = db.tblCompanyes.Find(id);
            return View(insp);
        }
        // GET: /Company/Details/5
        public ActionResult Details(decimal id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            tblCompanye tblcompanye = db.tblCompanyes.Find(id);
            if (tblcompanye == null)
            {
                return HttpNotFound();
            }
            return View(tblcompanye);
        }

        // GET: /Company/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: /Company/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(tblCompanye inspection, HttpPostedFileBase file1)
        {
            if (ModelState.IsValid)
            {
                string filename = "";
                byte[] bytes;
                int BytestoRead;
                int numBytesRead;

                if (file1 != null)
                {
                    filename = Path.GetFileName(file1.FileName);
                    bytes = new byte[file1.ContentLength];
                    BytestoRead = (int)file1.ContentLength;
                    numBytesRead = 0;
                    while (BytestoRead > 0)
                    {
                        int n = file1.InputStream.Read(bytes, numBytesRead, BytestoRead);
                        if (n == 0) break;
                        numBytesRead += n;
                        BytestoRead -= n;
                    }
                    inspection.CompLogo = bytes;
                }
                //inspection.CompID=
                inspection.CompID = Common.GetMaxIDInt("tblCompanyes", "CompID");
                inspection.InsertedBy = "Base";//Session["USERID"].ToString().Trim();
                inspection.InsertedOn = System.DateTime.Now;

                db.tblCompanyes.Add(inspection);
                db.SaveChanges();
                return RedirectToAction("Index");

            }

            return View(inspection);
        }

        //public ActionResult Create([Bind(Include="CompID,CompCode,CompName,CompAddr,PhoneNo,MobileNo,Fax,Email,WebURL,CompLogo,RefID,InsertedBy,InsertedOn,UpdatedBy,UpdatedOn,IsActive")] tblCompanye tblcompanye)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.tblCompanyes.Add(tblcompanye);
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }

        //    return View(tblcompanye);
        //}

        // GET: /Company/Edit/5
        public ActionResult Edit(decimal id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            tblCompanye tblcompanye = db.tblCompanyes.Find(id);
            if (tblcompanye == null)
            {
                return HttpNotFound();
            }
            return View(tblcompanye);
        }

        // POST: /Company/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]

        //public ActionResult Edit([Bind(Include="CompID,CompCode,CompName,CompAddr,PhoneNo,MobileNo,Fax,Email,WebURL,CompLogo,RefID,InsertedBy,InsertedOn,UpdatedBy,UpdatedOn,IsActive")] tblCompanye tblcompanye)
        public ActionResult Edit(tblCompanye inspection, HttpPostedFileBase file1)
        {

            if (ModelState.IsValid)
            {
                string filename = "";
                byte[] bytes;
                int BytestoRead;
                int numBytesRead;

                if (file1 != null)
                {
                    filename = Path.GetFileName(file1.FileName);
                    bytes = new byte[file1.ContentLength];
                    BytestoRead = (int)file1.ContentLength;
                    numBytesRead = 0;
                    while (BytestoRead > 0)
                    {
                        int n = file1.InputStream.Read(bytes, numBytesRead, BytestoRead);
                        if (n == 0) break;
                        numBytesRead += n;
                        BytestoRead -= n;
                    }
                    inspection.CompLogo = bytes;
                }
                inspection.UpdatedBy = "Base";//Session["USERID"].ToString().Trim();
                inspection.UpdatedOn = System.DateTime.Now;
                db.tblCompanyes.Add(inspection);
                db.Entry(inspection).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
          

          


            //if (ModelState.IsValid)
            //{
            //    db.Entry(tblcompanye).State = EntityState.Modified;
            //    db.SaveChanges();
            //    return RedirectToAction("Index");
            //}
            return View(inspection);
        }

        // GET: /Company/Delete/5
        public ActionResult Delete(decimal id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            tblCompanye tblcompanye = db.tblCompanyes.Find(id);
            if (tblcompanye == null)
            {
                return HttpNotFound();
            }
            return View(tblcompanye);
        }

        // POST: /Company/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(decimal id)
        {
            tblCompanye tblcompanye = db.tblCompanyes.Find(id);
            db.tblCompanyes.Remove(tblcompanye);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }


In Views:


CREATE:



@model BLRS.Models.tblCompanye

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Company Create</title>
</head>
<body>
    <form name="datapluspics" method="post" enctype="multipart/form-data">
        @*@using (Html.BeginForm())
            {*@
        @Html.AntiForgeryToken()

        <div class="form-horizontal">
            <h4>tblCompanye</h4>
            <hr />
            @Html.ValidationSummary(true)

            @*<div class="form-group">
                @Html.LabelFor(model => model.CompID, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CompID)
                    @Html.ValidationMessageFor(model => model.CompID)
                </div>
            </div>*@

            <div class="form-group">
                @Html.LabelFor(model => model.CompCode, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CompCode)
                    @Html.ValidationMessageFor(model => model.CompCode)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CompName, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CompName)
                    @Html.ValidationMessageFor(model => model.CompName)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CompAddr, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CompAddr)
                    @Html.ValidationMessageFor(model => model.CompAddr)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.PhoneNo, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.PhoneNo)
                    @Html.ValidationMessageFor(model => model.PhoneNo)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.MobileNo, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.MobileNo)
                    @Html.ValidationMessageFor(model => model.MobileNo)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Fax, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Fax)
                    @Html.ValidationMessageFor(model => model.Fax)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Email, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Email)
                    @Html.ValidationMessageFor(model => model.Email)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.WebURL, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.WebURL)
                    @Html.ValidationMessageFor(model => model.WebURL)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CompLogo, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    <input type="file" id="file1" name="file1" />
                    @*@Html.EditorFor(model => model.CompLogo)
                    @Html.ValidationMessageFor(model => model.CompLogo)*@
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.RefID, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.RefID)
                    @Html.ValidationMessageFor(model => model.RefID)
                </div>
            </div>

            @*<div class="form-group">
                @Html.LabelFor(model => model.InsertedBy, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.InsertedBy)
                    @Html.ValidationMessageFor(model => model.InsertedBy)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.InsertedOn, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.InsertedOn)
                    @Html.ValidationMessageFor(model => model.InsertedOn)
                </div>
            </div>*@

            @*<div class="form-group">
                @Html.LabelFor(model => model.UpdatedBy, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.UpdatedBy)
                    @Html.ValidationMessageFor(model => model.UpdatedBy)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.UpdatedOn, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.UpdatedOn)
                    @Html.ValidationMessageFor(model => model.UpdatedOn)
                </div>
            </div>*@

            <div class="form-group">
                @Html.LabelFor(model => model.IsActive, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.CheckBoxFor(model => model.IsActive)
                    @Html.ValidationMessageFor(model => model.IsActive)
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Create" class="btn btn-default" />
                </div>
            </div>
        </div>
    </form>

        <div>
            @Html.ActionLink("Back to List", "Index")
        </div>
</body>
</html>
DELETE:
@model BLRS.Models.tblCompanye

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Delete</title>
</head>
<body>
    <h3>Are you sure you want to delete this?</h3>
    <div>
        <h4>tblCompanye</h4>
        <hr />
        <dl class="dl-horizontal">
            <dt>
                @Html.DisplayNameFor(model => model.CompCode)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.CompCode)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.CompName)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.CompName)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.CompAddr)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.CompAddr)
            </dd>
   

        </dl>
   
        @using (Html.BeginForm()) {
            @Html.AntiForgeryToken()
   
            <div class="form-actions no-color">
                <input type="submit" value="Delete" class="btn btn-default" /> |
                @Html.ActionLink("Back to List", "Index")
            </div>
        }
    </div>
</body>
</html>

Details:
@model BLRS.Models.tblCompanye

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Companye Detail</title>
</head>
<body>
    <div>
        <h4>Companye Detail</h4>
        <hr />
        <dl class="dl-horizontal">
            <dt>
                @Html.DisplayNameFor(model => model.CompCode)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.CompCode)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.CompName)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.CompName)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.CompAddr)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.CompAddr)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.PhoneNo)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.PhoneNo)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.MobileNo)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.MobileNo)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.Fax)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.Fax)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.Email)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.Email)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.WebURL)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.WebURL)
            </dd>
   
            <dt>
              @Html.DisplayNameFor(model => model.CompLogo)
            </dt>
   
            <dd>
                @*@Html.DisplayFor(model => model.CompLogo)*@
             
                @if (Model.CompLogo != null)
                {
                    <img alt="tag" src="@Url.Content("/Company/MyImage?id=" + Model.CompID + "&img=1")" />
                }
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.RefID)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.RefID)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.InsertedBy)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.InsertedBy)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.InsertedOn)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.InsertedOn)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.UpdatedBy)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.UpdatedBy)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.UpdatedOn)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.UpdatedOn)
            </dd>
   
            <dt>
                @Html.DisplayNameFor(model => model.IsActive)
            </dt>
   
            <dd>
                @Html.DisplayFor(model => model.IsActive)
            </dd>
   
        </dl>
    </div>
    <p>
        @Html.ActionLink("Edit", "Edit", new { id = Model.CompID }) |
        @Html.ActionLink("Back to List", "Index")
    </p>
</body>
</html>
EDIT:
@model BLRS.Models.tblCompanye

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
</head>
<body>
    @*@using (Html.BeginForm())
    {*@
    <form name="datapluspics" method="post" enctype="multipart/form-data">
        @Html.AntiForgeryToken()

        <div class="form-horizontal">
            <h4>Edit Companye</h4>
            <hr />
            @Html.ValidationSummary(true)
            @Html.HiddenFor(model => model.CompID)
            @Html.HiddenFor(model => model.InsertedOn)
            @Html.HiddenFor(model => model.InsertedBy)

            <div class="form-group">
                @Html.LabelFor(model => model.CompCode, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CompCode)
                    @Html.ValidationMessageFor(model => model.CompCode)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CompName, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CompName)
                    @Html.ValidationMessageFor(model => model.CompName)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CompAddr, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CompAddr)
                    @Html.ValidationMessageFor(model => model.CompAddr)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.PhoneNo, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.PhoneNo)
                    @Html.ValidationMessageFor(model => model.PhoneNo)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.MobileNo, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.MobileNo)
                    @Html.ValidationMessageFor(model => model.MobileNo)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Fax, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Fax)
                    @Html.ValidationMessageFor(model => model.Fax)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Email, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Email)
                    @Html.ValidationMessageFor(model => model.Email)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.WebURL, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.WebURL)
                    @Html.ValidationMessageFor(model => model.WebURL)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CompLogo, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    <input type="file" id="file1" name="file1" />
                    @if (Model.CompLogo != null)
                        {
                            <img alt="tag" src="@Url.Content("/Company/MyImage?id=" + Model.CompID + "&img=1")" />
                        }
                    @*@Html.EditorFor(model => model.CompLogo)
                    @Html.ValidationMessageFor(model => model.CompLogo)*@
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.RefID, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.RefID)
                    @Html.ValidationMessageFor(model => model.RefID)
                </div>
            </div>
@*
    <div class="form-group">
        @Html.LabelFor(model => model.InsertedBy, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.InsertedBy)
            @Html.ValidationMessageFor(model => model.InsertedBy)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.InsertedOn, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.InsertedOn)
            @Html.ValidationMessageFor(model => model.InsertedOn)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.UpdatedBy, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.UpdatedBy)
            @Html.ValidationMessageFor(model => model.UpdatedBy)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.UpdatedOn, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.UpdatedOn)
            @Html.ValidationMessageFor(model => model.UpdatedOn)
        </div>
    </div>*@

            <div class="form-group">
                @Html.LabelFor(model => model.IsActive, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.IsActive)
                    @Html.ValidationMessageFor(model => model.IsActive)
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Save" class="btn btn-default" />
                </div>
            </div>
        </div>
    </form>

        <div>
            @Html.ActionLink("Back to List", "Index")
        </div>
</body>
</html>

Index:

@model IEnumerable<BLRS.Models.tblCompanye>

@{
    ViewBag.Title = "Index";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <br />
    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
    <table class="table">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.CompCode)
            </th>
            <th>            
                Logo
            </th>
            <th>
                @Html.DisplayNameFor(model => model.CompName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.CompAddr)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.PhoneNo)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.MobileNo)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Fax)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Email)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.WebURL)
            </th>
            @*<th>
                @Html.DisplayNameFor(model => model.CompLogo)
                Logo
            </th>*@
            @*<th>
                @Html.DisplayNameFor(model => model.RefID)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.InsertedBy)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.InsertedOn)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.UpdatedBy)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.UpdatedOn)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.IsActive)
            </th>*@
            <th></th>
        </tr>
   
    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.CompCode)
            </td>
            <td>
                @*@Html.DisplayFor(modelItem => item.CompLogo)*@
                @if (item.CompLogo != null)
                {
                    <img alt="tag" src="@Url.Content("/Company/MyImage?id=" + item.CompID + "&img=1")" />
                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.CompName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.CompAddr)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.PhoneNo)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.MobileNo)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Fax)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Email)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.WebURL)
            </td>
            @*<td>
             
                @if (item.CompLogo != null)
                {
                    <img alt="tag" src="@Url.Content("/CImage/MyImage?id=" + item.CompID + "&img=1")" /> 
                }
            </td>*@
            @*<td>
                @Html.DisplayFor(modelItem => item.RefID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.InsertedBy)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.InsertedOn)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UpdatedBy)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UpdatedOn)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsActive)
            </td>*@
            <td>
                @Html.ActionLink("Edit", "Edit", new { id=item.CompID }) |
                @Html.ActionLink("Details", "Details", new { id=item.CompID }) |
                @Html.ActionLink("Delete", "Delete", new { id=item.CompID })
            </td>
        </tr>
    }
   
    </table>
</body>
</html>
MyImage:(For Image Upload)
@model BLRS.Models.tblCompanye

@{
    if (ViewBag.Pic == 1)
    {
        if (Model.CompLogo != null)
        {
            WebImage wi = new WebImage(Model.CompLogo);
            wi.Resize(150, 150, true, true);
            wi.Write();
        }
    }
}

Conventions

The amount of code you had to write in order for the Entity Framework to be able to create a complete database for you is minimal because of the use of conventions, or assumptions that the Entity Framework makes. Some of them have already been noted or were used without your being aware of them:
  • The pluralized forms of entity class names are used as table names.
  • Entity property names are used for column names.
  • Entity properties that are named ID or classnameID are recognized as primary key properties. 
  • A property is interpreted as a foreign key property if it's named <navigation property name><primary key property name> (for example, StudentID for the Student navigation property since the Student entity's primary key is ID). Foreign key properties can also be named the same simply <primary key property name> (for example, EnrollmentID since the Enrollment entity's primary key is EnrollmentID).