예제 #1
0
        public FOBModel GetStorageData(int Id)
        {
            ShomaRMEntities db    = new ShomaRMEntities();
            FOBModel        model = new FOBModel();

            var GetStorageData = db.tbl_FOB.Where(p => p.StorageID == Id).FirstOrDefault();

            if (GetStorageData != null)
            {
                model.StorageID   = GetStorageData.StorageID;
                model.PropertyID  = GetStorageData.PropertyID;
                model.StorageName = GetStorageData.StorageName;
                model.Charges     = GetStorageData.Charges;
                model.Description = GetStorageData.Description;
            }
            model.StorageID = Id;
            return(model);
        }
예제 #2
0
        public List <FOBModel> GetStorageList()
        {
            ShomaRMEntities db    = new ShomaRMEntities();
            List <FOBModel> model = new List <FOBModel>();

            try
            {
                DataTable dtTable = new DataTable();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_Get_FOB";
                    cmd.CommandType = CommandType.StoredProcedure;

                    //DbParameter paramC = cmd.CreateParameter();
                    //paramC.ParameterName = "Criteria";
                    //paramC.Value = MarketSourceName;
                    //cmd.Parameters.Add(paramC);

                    DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter();
                    da.SelectCommand = cmd;
                    da.Fill(dtTable);
                    db.Database.Connection.Close();
                }
                foreach (DataRow dr in dtTable.Rows)
                {
                    FOBModel usm = new FOBModel();
                    usm.StorageID   = int.Parse(dr["StorageID"].ToString());
                    usm.PropertyID  = int.Parse(dr["PropertyID"].ToString());
                    usm.StorageName = dr["StorageName"].ToString();
                    usm.Charges     = Convert.ToDecimal(dr["Charges"].ToString());
                    usm.Description = dr["Description"].ToString();
                    model.Add(usm);
                }
                db.Dispose();
                return(model.ToList());
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }
        }
예제 #3
0
        public FOBModel GetStorageInfo(int ID = 0)
        {
            ShomaRMEntities db    = new ShomaRMEntities();
            FOBModel        model = new FOBModel();

            model.StorageID   = 0;
            model.StorageName = "";

            var StorageInfo = db.tbl_FOB.Where(p => p.StorageID == StorageID).FirstOrDefault();

            if (StorageInfo != null)
            {
                model.StorageID   = StorageInfo.StorageID;
                model.PropertyID  = StorageInfo.PropertyID;
                model.StorageName = StorageInfo.StorageName;
                model.Charges     = StorageInfo.Charges;
                model.Description = StorageInfo.Description;
            }

            return(model);
        }
예제 #4
0
        public long SaveUpdateStorage(FOBModel model)
        {
            ShomaRMEntities db = new ShomaRMEntities();

            if (model.StorageID == 0)
            {
                var StorageData = new tbl_FOB()
                {
                    PropertyID  = model.PropertyID,
                    StorageName = model.StorageName,
                    Charges     = model.Charges,
                    Description = model.Description
                };
                db.tbl_FOB.Add(StorageData);
                db.SaveChanges();
                model.StorageID = StorageData.StorageID;
            }
            else
            {
                var StorageInfo = db.tbl_FOB.Where(p => p.StorageID == model.StorageID).FirstOrDefault();
                if (StorageInfo != null)
                {
                    StorageInfo.PropertyID  = model.PropertyID;
                    StorageInfo.StorageName = model.StorageName;
                    StorageInfo.Charges     = model.Charges;
                    StorageInfo.Description = model.Description;
                    db.SaveChanges();
                }
                else
                {
                    throw new Exception(model.StorageName + " not exists in the system.");
                }
            }

            return(model.StorageID);
        }