public ActionResult Create(int id = 0)
        {
            TruckAssignVM VM = new TruckAssignVM();

            if (id > 0)
            {
                var c = db.TruckDetails.Find(id);
                VM.TruckDetailId = c.TruckDetailID;
                VM.VehicleID     = c.VehicleID;
                VM.VechicleName  = db.VehicleMasters.Find(c.VehicleID).RegistrationNo + "-" + c.DriverName;
                VM.ReceiptNo     = c.ReceiptNo;
                VM.TDDate        = c.TDDate;
                VM.RouteID       = Convert.ToInt32(c.RouteID);
                VM.RouteName     = db.RouteMasters.Find(VM.RouteID).RouteName;
                ViewBag.EditMode = "True";
                ViewBag.Title    = "Truck Assign - Modify";
            }
            else
            {
                ViewBag.EditMode = "False";
                VM.TruckDetailId = 0;
                ViewBag.Title    = "Truck Assign - Create";
            }

            return(View(VM));
        }
Exemple #2
0
        public static List <TruckAssignVM> GetTruckDetailConsignments(string TDHNo, string ConsignmentNote, DateTime FromDate, DateTime ToDate)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = new SqlConnection(CommanFunctions.GetConnectionString);
            cmd.CommandText = "SP_GetTruckAssignList";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@FromDate", SqlDbType.VarChar);
            cmd.Parameters["@FromDate"].Value = FromDate.ToString("MM/dd/yyyy");
            cmd.Parameters.Add("@ToDate", SqlDbType.VarChar);
            cmd.Parameters["@ToDate"].Value = ToDate.ToString("MM/dd/yyyy");
            cmd.Parameters.Add("@ConsignmentNo", SqlDbType.VarChar);
            if (ConsignmentNote == null)
            {
                ConsignmentNote = "";
            }
            cmd.Parameters["@ConsignmentNo"].Value = ConsignmentNote;

            cmd.Parameters.Add("@TDHNo", SqlDbType.VarChar);
            if (TDHNo == null)
            {
                TDHNo = "";
            }
            cmd.Parameters["@TDHNo"].Value = TDHNo;

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);

            List <TruckAssignVM> objList = new List <TruckAssignVM>();

            if (ds != null && ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    TruckAssignVM obj = new TruckAssignVM();
                    obj.TruckDetailId         = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["TruckDetailId"].ToString());
                    obj.ReceiptNo             = ds.Tables[0].Rows[i]["ReceiptNo"].ToString();
                    obj.ConsignmentNo         = ds.Tables[0].Rows[i]["ConsignmentNo"].ToString();
                    obj.TDDate                = Convert.ToDateTime(ds.Tables[0].Rows[i]["TDDate"].ToString()); // CommanFunctions.ParseDate(ds.Tables[0].Rows[i]["RecPayDate"].ToString());
                    obj.RouteName             = ds.Tables[0].Rows[i]["RouteName"].ToString();
                    obj.VechileRegistrationNo = ds.Tables[0].Rows[i]["RegNo"].ToString();
                    obj.Rent         = Convert.ToDecimal(ds.Tables[0].Rows[i]["Rent"].ToString());
                    obj.OtherCharges = Convert.ToDecimal(ds.Tables[0].Rows[i]["OtherCharge"].ToString());
                    obj.TotalCharge  = Convert.ToDecimal(ds.Tables[0].Rows[i]["TotalCharge"].ToString());
                    objList.Add(obj);
                }
            }
            return(objList);
        }