public bool Add(PRICE price) { NameValueCollection nvm = new NameValueCollection(); nvm.Clear(); nvm["email"] = uid; nvm["password"] = upass; nvm["amount"] = price.amount; nvm["gp"] = price.gp; nvm["promo"] = price.promo; nvm["days"] = price.days; nvm["paypal"] = price.paypal; nvm["save"] = price.savings; nvm["mode"] = "0"; //MODE = 0, add new price string resp = web.PostPage(pricesetremote, nvm, 0, 0); if (resp == string.Empty) { return(false); } else if (resp.Contains("RES:SUCCESS")) { return(true); } else { return(false); } }
public bool Update() { using (SqlConnection connection = new SqlConnection(CONSTANT.connectBD)) { string sqlExpression = @" UPDATE [SPAVREMONT].[USLUGS_SHOP] SET [ID_SHOP] ='" + ID_SHOP + @"' ,[ID_USLUG] ='" + Uslug.ID_USLUG + @"' ,[PRICE] =" + PRICE.ToString() + @" ,[NOTE_USLUGS_SHOP] ='" + NOTE_USLUGS_SHOP + @"' WHERE [ID_USLUGS_SHOP]='" + ID_USLUGS_SHOP + @"' "; connection.Open(); SqlCommand command = new SqlCommand(); command.CommandText = sqlExpression; command.Connection = connection; int numb = command.ExecuteNonQuery(); // если успешно вставились данные if (numb > 0) { return(true); } } return(false); }
public ActionResult Edit(ModelViewModel modelData) { if (ModelState.IsValid) { MODEL model = new MODEL() { ID = modelData.ID, ID_TYPE = modelData.ID_TYPE, NAME = modelData.NAME }; modelRepository.Update(model); modelRepository.Save(); if (modelData.currentCoast != modelData.oldCoast) { PRICE price = new PRICE() { COAST = Convert.ToDecimal(modelData.currentCoast), ID_MODEL = Convert.ToDecimal(modelData.ID), DATE_ADD = DateTime.Now }; priceRepository.Create(price); priceRepository.Save(); } return(RedirectToAction("Index")); } return(View(modelData)); }
public ActionResult DeleteConfirmed(int id) { PRICE price = db.PRICEs.Find(id); db.PRICEs.Remove(price); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult getPrice(int id) { DateTime now = DateTime.Now; PRICE price = spDAO.GetPriceBySanPham(id); //PRICE price = await db.PRICE.SingleOrDefaultAsync<PRICE>(x => x.SANPHAM_ID == id && //(x.BATDAU<= now && x.KETTHUC >=now || x.BATDAU <= now && x.KETTHUC == null)); return(Ok(price.GIABAN)); }
public static INSURANCE_TBL the_worth_hmo(int age, string categoryName) { categ = db.CATEGORIES_TBL.Where(g => g.categoryName == categoryName).FirstOrDefault(); prod = db.PRODUCTS_TBL.Where(g => g.categoryId == categ.categoriesId).FirstOrDefault(); price1 = db.PRICEs.Where(g => g.productId == prod.productId).FirstOrDefault(); insurance = db.INSURANCE_TBL.Where(g => g.insuranceId == price1.insuranceId).FirstOrDefault(); //age = db.AGE_TBL.Where(g => g.begins >= age && s=>s.ends <= age).FirstOrDefault(); return(insurance); }
private void button2_Click(object sender, EventArgs e) { YARDID.Clear(); YARDNAMEID.Clear(); YARDADDRESSID.Clear(); OPENTIME.Clear(); PRICE.Clear(); BOOKCONDITION.Clear(); }
// // GET: /PRICEAdmin/Details/5 public ActionResult Details(int id = 0) { PRICE price = db.PRICEs.Find(id); if (price == null) { return(HttpNotFound()); } return(View(price)); }
public ActionResult Edit(PRICE price) { if (ModelState.IsValid) { db.Entry(price).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(price)); }
public async Task <IHttpActionResult> GetPRICE(int id) { PRICE pRICE = await db.PRICE.FindAsync(id); if (pRICE == null) { return(NotFound()); } return(Ok(pRICE)); }
public ActionResult Create(PRICE price) { if (ModelState.IsValid) { db.PRICEs.Add(price); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(price)); }
public async Task <IHttpActionResult> PostPRICE(PRICE pRICE) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } prDAO.InsertPrice(pRICE); //db.PRICE.Add(pRICE); //await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = pRICE.ID }, pRICE)); }
public void UpdatePrice(PRICE price) { string query = "UpdatePrice"; string[] para = new string[2] { "@idSP", "@giaban" }; object[] value = new object[2] { price.SANPHAM_ID, price.GIABAN }; cn.Excute_Sql(query, CommandType.StoredProcedure, para, value); }
public static PRICE GetProductPrice(PRODUCTS_TBL product) { using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities()) { var productdetail = ProductsCRUD.ReadById(ctx, product.productId); if (productdetail != null) { PRICE price = ctx.PRICEs.Where(u => u.productId == product.productId).FirstOrDefault(); return(price); } return(null); } }
public async Task <IHttpActionResult> DeletePRICE(int id) { PRICE pRICE = await db.PRICE.FindAsync(id); if (pRICE == null) { return(NotFound()); } db.PRICE.Remove(pRICE); await db.SaveChangesAsync(); return(Ok(pRICE)); }
static void Main(string[] args) { const double PRICE = 14.99; const double TAX = 0.08; var name = ""; var address = ""; var city = ""; var state = ""; var zip = ""; double shirts = 0; double total = 0.0; double personalTax = 0.0; double grandTotal = 0.0; Write(" Enter your name: "); name = Convert.ToString(ReadLine()); Write(" Street address: "); address = Convert.ToString(ReadLine()); Write(" City: "); city = Convert.ToString(ReadLine()); Write(" State: "); state = Convert.ToString(ReadLine()); Write(" Zip: "); zip = Convert.ToString(ReadLine()); Write(" How many T-Shirts did you want to order? "); shirts = Convert.ToDouble(ReadLine()); total = (shirts * PRICE); personalTax = (total * TAX); grandTotal = (total + (total * TAX)); WriteLine("\n\n Reciept for: \n " + name); WriteLine(" " + address); WriteLine(" " + city + ", " + state + " " + zip); WriteLine(" " + shirts + " shirts ordered @ " + PRICE.ToString("C2") + " each"); WriteLine("\n Total:\t " + total.ToString("C2")); WriteLine(" Tax:\t " + personalTax.ToString("C2")); WriteLine("----------------"); WriteLine(" Due:\t " + grandTotal.ToString("C2")); WriteLine(" Press any key to continue . . ."); ReadLine(); }
// GET: Delete public ActionResult Delete(int?id) { if (id == null) { return(HttpNotFound()); } PRICE price = priceRepository.GetAllList().FirstOrDefault(x => x.ID.Equals(Convert.ToDecimal(id))); if (price == null) { return(HttpNotFound()); } return(View(price)); }
public PRICE GetPriceBySanPham(int id) { DateTime now = DateTime.Now; string query = "select * from dbo.getPriceBySanPham(@id)"; string[] para = new string[1] { "@id" }; object[] value = new object[1] { id }; DataTable tb = cn.FillDataTable(query, CommandType.Text, para, value); PRICE pr = cn.ConvertToList <PRICE>(tb)[0]; return(pr); }
public static PRICE_DTO CastToDTO(PRICE a) { return(new PRICE_DTO { priceText = a.priceText, priceId = a.priceId, productId = a.productId, ageId = a.ageId, discount = a.discount, insuranceId = a.insuranceId, productName = a.PRODUCTS_TBL.name, ageRange = a.AGE_TBL.begins + "-" + a.AGE_TBL.ends, hmoName = a.INSURANCE_TBL.HMO_TBL.hmoName, insuranceName = a.INSURANCE_TBL.insuranceName }); }
private void btnLuu_Click(object sender, EventArgs e) { SANPHAM1 sp1 = new SANPHAM1(); sp1.KHOILUONG = (int)spKL.Value; sp1.ANH = "/Resources/Image/" + System.IO.Path.GetFileName(picAnh.ImageLocation); sp1.MOTA = webMota.Document.InvokeScript("getValue").ToString(); sp1.LOAISP_ID = (int)cbBLSP.SelectedValue; int row = flag == 1 ? grViewSP.RowCount : grViewSP.FocusedRowHandle; if (flag == 1) { sp1.SOLUONG = 0; spDAO.insertSANPHAM(sp1); SANPHAM sp2 = spDAO.GetLastSanpham(); PRICE pr = new PRICE(); pr.GIABAN = Convert.ToInt32(txtGia.Text); pr.BATDAU = DateTime.Now; pr.KETTHUC = (DateTime?)null; pr.SANPHAM_ID = sp2.ID; new PriceDAO().insertPrice(pr); MessageBox.Show("Thêm thành công!"); } if (flag == 2) { sp1.ID = sp.ID; sp1.SOLUONG = sp.SOLUONG; spDAO.updateSANPHAM(sp1); PRICE pr = new PriceDAO().getPriceBySanphamId(sp.ID); pr.GIABAN = Convert.ToInt32(txtGia.Text); new PriceDAO().updatePrice(pr); MessageBox.Show("Update thành công!"); } string despath = @"E:\Projects\DEPLOY IIS\QuanCafeAPI IIS" + sp1.ANH; if (!File.Exists(despath)) { File.Copy(picAnh.ImageLocation, despath); } //grCtrlSP.DataSource = spDAO.getListSANPHAM(); flag = 0; LoadData(); grViewSP.FocusedRowHandle = row; Hienthi(); }
public async Task <IHttpActionResult> PutPRICE(PRICE pRICE) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //db.Entry(pRICE).State = EntityState.Modified; try { prDAO.UpdatePrice(pRICE); //await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult PriceChange(ModelViewModel modelData) { if (ModelState.IsValid) { PRICE price = new PRICE() { COAST = Convert.ToDecimal(modelData.currentCoast), ID_MODEL = Convert.ToDecimal(modelData.ID), DATE_ADD = DateTime.Now }; priceRepository.Create(price); priceRepository.Save(); return(RedirectToAction("Index")); } else { return(HttpNotFound()); } }
public bool CreateItemsBuy() { using (SqlConnection connection = new SqlConnection(CONSTANT.connectBD)) { string sqlExpression = @" INSERT INTO [SPAVREMONT].[ITEMS_BUY] ( [ID_ITEMS_BUY] ,[ID_ITEMS_SHOP] ,[NAME_IB] ,[NOTE_IB] ,[IMG_URL] ,[PRICE] ) VALUES ( '" + Guid.NewGuid().ToString() + @"' --[ID_ITEMS_BUY] ,'" + ID_ITEMS_SHOP + @"' --[ID_ITEMS_SHOP] ,'" + NAME_IB + @"' --[NAME_IB] ,'" + NOTE_IB + @"' --[NOTE_IB] ,'" + IMG_URL + @"' --[IMG_URL] ," + PRICE.ToString() + @" --[PRICE] ) "; connection.Open(); SqlCommand command = new SqlCommand(); command.CommandText = sqlExpression; command.Connection = connection; int numbInsUser = command.ExecuteNonQuery(); // если успешно вставились данные if (numbInsUser > 0) { return(true); } } return(false); }
public bool CreateUslugShop() { using (SqlConnection connection = new SqlConnection(CONSTANT.connectBD)) { string sqlExpression = @" INSERT INTO [SPAVREMONT].[USLUGS_SHOP] ( [ID_USLUGS_SHOP] ,[ID_SHOP] ,[ID_USLUG] ,[PRICE] ,[NOTE_USLUGS_SHOP] ) VALUES( '" + Guid.NewGuid().ToString() + @"'--[ID_USLUGS_SHOP] ,'" + ID_SHOP + @"' --[ID_SHOP] ,'" + Uslug.ID_USLUG + @"' --[ID_USLUG] ," + PRICE.ToString() + @"--[PRICE] ,'" + NOTE_USLUGS_SHOP + @"' --[NOTE_USLUGS_SHOP] ) "; connection.Open(); SqlCommand command = new SqlCommand(); command.CommandText = sqlExpression; command.Connection = connection; int numbInsUser = command.ExecuteNonQuery(); // если успешно вставились данные if (numbInsUser > 0) { return(true); } } return(false); }
public ActionResult Create(ModelViewModel modelData) { if (ModelState.IsValid) { MODEL model = new MODEL() { ID_TYPE = modelData.ID_TYPE, NAME = modelData.NAME }; IEnumerable <MODEL> sameModel = modelRepository.GetAllList().Where(x => x.NAME.Equals(modelData.NAME) && x.ID_TYPE.Equals(modelData.ID_TYPE)); if (sameModel != null) { modelRepository.Create(model); modelRepository.Save(); } else { return(HttpNotFound()); } MODEL modelFind = modelRepository.GetAllList().Where(x => x.NAME.Equals(modelData.NAME) && x.ID_TYPE.Equals(modelData.ID_TYPE)).First(); PRICE price = new PRICE() { COAST = Convert.ToDecimal(modelData.currentCoast), ID_MODEL = Convert.ToDecimal(modelFind.ID), DATE_ADD = DateTime.Now }; priceRepository.Create(price); priceRepository.Save(); return(RedirectToAction("Index")); } return(View(modelData)); }
public void insertPrice(PRICE pr) { cn.Post <PRICE>("api/PRICE/", pr); }
public void updatePrice(PRICE pr) { cn.Put <PRICE>("api/PRICE/", pr); }
public ActionResult GetCost(string qty, string zipcode) { int BOX_CASE = 5; int CASE_WT = 5; int UT_WT = 1; int Qty = 100; int diff = 0; int nrBoxes = 0; int itemsInLastBox = 0; int valuePerFullBox = 0; int valuePerPartialBox = 0; decimal unitPrice = 14; string szError = ""; string szMsg = ""; string szItemId = "DF4011"; string fullBoxWeight = ""; string partialBoxWeight = ""; //UPSinv_detl details = null; inv_detl details = null; ITEM item = null; PRICE price = null; try { if (string.IsNullOrEmpty(qty)) { Qty = 50; } else { Qty = Convert.ToInt32(qty); } //details = new UPSinv_detl(); details = new inv_detl(); details.CASE_HI = 5; details.CASE_LEN = 5; details.CASE_WI = 5; price = db.PRICEs.Where(prc => prc.Item == szItemId && prc.Qty == Qty).FirstOrDefault <PRICE>(); if (price != null) { unitPrice = price.thePrice; } item = db.ITEMs.Where(itm => itm.ItemID == szItemId).FirstOrDefault <ITEM>(); if (item != null) { BOX_CASE = Convert.ToInt16(item.UnitPerCase); CASE_WT = Convert.ToInt32(item.CaseWeight); UT_WT = Convert.ToInt32(item.UnitWeight); details.CASE_HI = Convert.ToDecimal(item.CaseDimensionH); details.CASE_LEN = Convert.ToDecimal(item.CaseDimensionL); details.CASE_WT = Convert.ToDecimal(item.CaseDimensionW); //Sample uses details.CASE_WT } nrBoxes = Qty / BOX_CASE; itemsInLastBox = Qty % BOX_CASE; fullBoxWeight = CASE_WT.ToString(); if (itemsInLastBox > 0) { partialBoxWeight = (itemsInLastBox * UT_WT).ToString(); } valuePerFullBox = BOX_CASE * Convert.ToInt32(unitPrice); diff = valuePerFullBox % 100; if (diff > 0) { valuePerFullBox = valuePerFullBox + (100 - diff); } valuePerPartialBox = itemsInLastBox * Convert.ToInt32(unitPrice); diff = valuePerPartialBox % 100; if (diff > 0) { valuePerPartialBox = valuePerPartialBox + (100 - diff); } //GetRateFromUPS(Qty, nrBoxes, itemsInLastBox, fullBoxWeight, valuePerFullBox, valuePerPartialBox, partialBoxWeight, details, unitPrice); GetRateFromUPS(Qty, nrBoxes, itemsInLastBox, fullBoxWeight, valuePerFullBox, valuePerPartialBox, partialBoxWeight, details, unitPrice); } catch (Exception err) { szMsg = string.Format("{0} {1}", err.Message, err.StackTrace); } return(View()); }