//一般結帳 public static string ItemToRowString(CheckOutProduct Co, int DivitionStatus) { string htmlTag = ""; string FontColor = ""; if (DivitionStatus == 2) { FontColor = "color:red"; } //贈品 //if (Co.IsBirthday) // htmlTag += string.Format("<tr class=\"item BirthdayPresent\" id=\"{0}_Item\"> ", Co.product_id); //else if (Co.IsPromotion) // htmlTag += string.Format("<tr class=\"item promotion\" id=\"{0}_Item\"> ", Co.product_id); //else // htmlTag += string.Format("<tr class=\"item\" id=\"{0}_Item\"> ", Co.product_id); htmlTag += string.Format("<tr class=\"item\" id=\"{0}_Item\" data-storefloat =\"{1}\" > ", Co.product_id, Co.IsStoreFloat); htmlTag += "<td style=\"width:20px;\" class=\"Delete_img\"></td>"; htmlTag += string.Format("<td style=\"width:60px;{0}\" class=\"itemNo\">{1}</td>", FontColor, Co.product_id); htmlTag += string.Format("<td style=\"width:142px;{0}\">{1}</td>", FontColor, Co.series_name); htmlTag += string.Format("<td style=\"width:48px;{0}\" class=\"color\">{1}</td>", FontColor, Co.color); htmlTag += string.Format("<td style=\"width:48px;{0}\">{1}</td>", FontColor, Co.size); htmlTag += string.Format("<td style=\"width:48px;{0}\" id=\"{1}_Qty\" class=\"quantity\">{2}</td>", FontColor, Co.product_id, Co.quantity); htmlTag += string.Format("<td style=\"width:48px;{0}\" ><strike style=\"display:none\" class=\"OriginalPrice\">{1}<br/></strike><span class=\"price\">{1}</span><input type=\"hidden\" class=\"discount_price\" value=\"{2}\" /><input type=\"hidden\" class=\"discount_type\" value=\"{3}\" /><input type=\"hidden\" class=\"VIP_discount_price\" value=\"{4}\" /><input type=\"hidden\" class=\"VIP_discount_type\" value=\"{5}\" /></td>", FontColor, Co.Original_price, Co.priceList, Co.DiscountType, Co.VipPriceList, Co.VIPDiscountType); htmlTag += string.Format("<td style=\"width:48px;{0}\" id=\"{1}_Amount\"><strike class=\"OriginalAmount\" style=\"display:none\">{2}<br/></strike><span class=\"amount\">{2}</span></td>", FontColor, Co.product_id, Co.Original_amount); htmlTag += string.Format("<td style=\"width:38px;{0}\" id=\"{1}_SkuQty\">{2}</td>", FontColor, Co.product_id, Co.StkQty); htmlTag += string.Format("<td style=\"width:38px;{0}\" id=\"{1}_ShowQty\">{2}</td></tr>", FontColor, Co.product_id, Co.ShowQty); return(htmlTag); }
public static string GetPromotionItemString(int amount, bool IsVip, bool IsBirthday, string PosNo) { string htmlTag = ""; DataTable promotionDT = get_pos_promotion(amount, IsVip, IsBirthday); ArrayList ItemList = new ArrayList(); foreach (DataRow row in promotionDT.Rows) { string SerialId = row["product_id"].ToString().Trim(); CheckOutProduct Co = GetPosCheckOutItem(SerialId); int.TryParse(row["bonus_multiplication"].ToString(), out Co.bonus_multiplication); Co.price = 0; if (IsBirthday) { Co.IsBirthday = true; } else { Co.IsPromotion = true; } string ItemString = GetcheckOutItemString(Co, "1", PosNo); dynamic d = JsonConvert.DeserializeObject <dynamic>(ItemString); ItemList.Add(d); } htmlTag = JsonConvert.SerializeObject(ItemList); return(htmlTag); }
public static string GetOrderItemByOrderID(string OrderID, int status) { string result = ""; StringBuilder s = new StringBuilder(); s.Append("select a.Status, a.OrderID,b.ProductId,d.Name ProductName,c.Color,c.Size size,b.Quantity,b.Price,b.Amount from Orders a "); if (status != 3) { s.Append("left join OrderItems b on a.OrderID=b.OrderID "); } else { s.Append("left join OrderItemsWaitCheckOut b on a.OrderID=b.OrderID "); } s.Append("left join Product c on b.ProductId=c.ProductId "); s.Append("left join ProductSerial d on c.SerialId=d.SerialId "); s.Append("where a.OrderID=@OrderID "); string sql = s.ToString(); Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("OrderID", OrderID); DataTable dt = DB.DBQuery(sql, param, "PosClient"); List <CheckOutProduct> OrderItemList = new List <CheckOutProduct>(); foreach (DataRow row in dt.Rows) { CheckOutProduct Co = new CheckOutProduct(); Co.product_id = row["ProductId"].ToString(); Co.series_name = row["ProductName"].ToString(); Co.color = row["Color"].ToString(); Co.size = row["Size"].ToString(); Co.price = int.Parse(row["Price"].ToString()); Co.quantity = int.Parse(row["Quantity"].ToString()); Co.StkQty = 0; int amount = Convert.ToInt16(row["Amount"].ToString()); result += ItemToRowString(Co, amount, 0); } return(result); }
//退貨用 public static string ItemToRowString(CheckOutProduct Co, int amount, int DivitionStatus) { string htmlTag = ""; string FontColor = ""; if (DivitionStatus == 2) { FontColor = "color:red"; } htmlTag += string.Format("<tr class=\"item\" id=\"{0}_Item\"> ", Co.product_id); htmlTag += "<td style=\"width:20px;\" class=\"Delete_img\"></td>"; htmlTag += string.Format("<td style=\"width:60px;{0}\" class=\"itemNo\">{1}</td>", FontColor, Co.product_id); htmlTag += string.Format("<td style=\"width:142px;{0}\">{1}</td>", FontColor, Co.series_name); htmlTag += string.Format("<td style=\"width:48px;{0}\" class=\"color\">{1}</td>", FontColor, Co.color); htmlTag += string.Format("<td style=\"width:48px;{0}\">{1}</td>", FontColor, Co.size); htmlTag += string.Format("<td style=\"width:48px;{0}\" id=\"{1}_Qty\" class=\"quantity\">{2}</td>", FontColor, Co.product_id, Co.quantity); htmlTag += string.Format("<td style=\"width:48px;{0}\" class=\"price\">{1}</td>", FontColor, Co.price); htmlTag += string.Format("<td style=\"width:48px;{0}\" id=\"{1}_Amount\" class=\"amount\">{2}</td>", FontColor, Co.product_id, amount); htmlTag += string.Format("<td style=\"width:38px;{0}\" id=\"{1}_SkuQty\">{2}</td>", FontColor, Co.product_id, Co.StkQty); htmlTag += string.Format("<td style=\"width:38px;{0}\" id=\"{1}_ShowQty\">{2}</td></tr>", FontColor, Co.product_id, Co.ShowQty); return(htmlTag); }
public static List <CheckOutProduct> GetTheSameSerialItemByProductID(string ProductID, string PosNo) { StringBuilder s = new StringBuilder(); s.Append("select a.SerialId,b.ProductId,a.Name,a.RefSerialId,b.SerialId,b.BarCode,b.Color,b.Size,b.Price "); s.Append("from posclient..ProductSerial a "); s.Append("join Product b on a.SerialId=b.SerialId "); s.Append("where (a.SerialId=(select c.SerialId from Product c where c.ProductId=@ProductID) or "); s.Append("RefSerialId=(select c.SerialId from Product c where c.ProductId= @ProductID) ) "); s.Append("and b.ProductId!=@ProductID "); s.Append("order by ProductId "); string sql = s.ToString(); Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("ProductID", ProductID); DataTable dt = DB.DBQuery(sql, param, "PosClient"); List <CheckOutProduct> CoList = new List <CheckOutProduct>(); foreach (DataRow dr in dt.Rows) { CheckOutProduct Co = new CheckOutProduct(); Co.product_id = dr["ProductId"].ToString(); Co.series_name = dr["Name"].ToString(); Co.size = dr["Size"].ToString(); Co.color = dr["Color"].ToString(); Co.barcode = dr["barcode"].ToString(); Co.price = int.Parse(dr["Price"].ToString()); int Show = GetShowQty(Co.product_id); int B1 = GetB1Qty(Co.product_id); int TempQuantityOthers = GetTempStorageQuantity(Co.product_id, PosNo); int TempQuantity = GetTempStorageQuantity(Co.product_id, ""); if (B1 - TempQuantity >= 0) { Co.StkQty = B1 - TempQuantityOthers; Co.ShowQty = Show; } else { if ((B1 - TempQuantity) + Show >= 0) { //B1不夠,展示夠的情況 if (B1 - TempQuantityOthers >= 0) { //B1減掉其他人的暫量後,庫存足夠 Co.StkQty = B1 - TempQuantityOthers; Co.ShowQty = Show; } else { //B1減掉其他人的暫量後,庫存不足夠 Co.StkQty = 0; Co.ShowQty = (B1 - TempQuantityOthers) + Show; } } } if (Co.price > 5000) { Co.price = 0; } CoList.Add(Co); } return(CoList); }
public static string GetcheckOutItemString(CheckOutProduct Co, string quantity, string PosNo) { string htmlTag = ""; bool HasProuduct = false; //儲位狀態 int DivitionStatus = 0; //沒有庫存:0,B1有庫存:1,B1無庫存,樓上有庫存 or B1有庫存但不夠,樓上夠:2 if (!string.IsNullOrEmpty(Co.product_id)) { HasProuduct = true; int Show = GetShowQty(Co.product_id); int B1 = GetB1Qty(Co.product_id); int TempQuantityOthers = GetTempStorageQuantity(Co.product_id, PosNo); int TempQuantity = GetTempStorageQuantity(Co.product_id, ""); if (B1 - TempQuantity - int.Parse(quantity) >= 0) { //B1庫存足夠的情況 UpdateStorageQuantity(Co.product_id, PosNo, quantity); DivitionStatus = 1; Co.StkQty = B1 - TempQuantityOthers; Co.ShowQty = Show; } else { if ((B1 - TempQuantity - int.Parse(quantity)) + Show >= 0) { //B1不夠,展示夠的情況 UpdateStorageQuantity(Co.product_id, PosNo, quantity); DivitionStatus = 2; if (B1 - TempQuantityOthers >= 0) { //B1減掉其他人的暫量後,庫存足夠 Co.StkQty = B1 - TempQuantityOthers; Co.ShowQty = Show; } else { //B1減掉其他人的暫量後,庫存不足夠 Co.StkQty = 0; Co.ShowQty = (B1 - TempQuantityOthers) + Show; } } else { UpdateStorageQuantity(Co.product_id, PosNo, quantity); DivitionStatus = 0; } } Co.quantity = int.Parse(quantity); Co.Original_price = Co.price; Co.Original_amount = Co.Original_price * int.Parse(quantity); //一般會員折扣 if (Co.DiscountType.Length > 0) { List <ParamData> ParamList = JsonConvert.DeserializeObject <List <ParamData> >(Co.DiscountParam); ArrayList PriceList = new ArrayList(); foreach (ParamData PD in ParamList) { int DiscountPrice = 0; if (Co.DiscountType != "新品折X元") { DiscountPrice = Convert.ToInt32(Math.Floor((double)Co.price * PD.Discount / 100)); } else { DiscountPrice = Co.price - PD.Discount; } PriceList.Add(DiscountPrice); } Co.priceList = JsonConvert.SerializeObject(PriceList); } else { Co.priceList = "[]"; } //VIP會員折扣 if (Co.VIPDiscountType.Length > 0) { List <ParamData> ParamList = JsonConvert.DeserializeObject <List <ParamData> >(Co.VIPDiscountParam); ArrayList PriceList = new ArrayList(); foreach (ParamData PD in ParamList) { int DiscountPrice = Convert.ToInt32(Math.Floor((double)Co.price * PD.Discount / 100)); PriceList.Add(DiscountPrice); } Co.VipPriceList = JsonConvert.SerializeObject(PriceList); } else { Co.VipPriceList = "[]"; } } htmlTag = ItemToRowString(Co, DivitionStatus); var result = new { result = HasProuduct, data = htmlTag, itemNo = Co.product_id, quantity = Co.quantity, original_amount = Co.Original_amount, amount = Co.amount, SkuQty = 2, ShowQty = 1, DivitionStatus = 1 }; //var result = new { result = HasProuduct, data = htmlTag, itemNo = Co.product_id, quantity = Co.quantity, original_amount = Co.Original_amount, amount = Co.amount, SkuQty = Co.StkQty, ShowQty = Co.ShowQty, DivitionStatus = DivitionStatus }; return(JsonConvert.SerializeObject(result)); }
public static CheckOutProduct GetPosCheckOutItem(string barcode) { StringBuilder sb = new StringBuilder(); sb.Append("select a.ProductId,a.BarCode,a.Price,a.Color,a.Size,b.Name,b.SerialId "); sb.Append("from PosClient..Product a "); sb.Append("left join ProductSerial b on a.SerialId=b.SerialId "); sb.Append("where a.SerialId=@barcode OR a.BarCode=@barcode "); string sql = sb.ToString(); Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("barcode", barcode); DataTable dt = DB.DBQuery(sql, param, "PosClient"); CheckOutProduct Co = new CheckOutProduct(); if (dt.Rows.Count > 0) { Co.product_id = dt.Rows[0]["ProductId"].ToString(); Co.SerialId = dt.Rows[0]["SerialId"].ToString(); Co.series_name = dt.Rows[0]["Name"].ToString(); Co.size = dt.Rows[0]["Size"].ToString(); Co.color = dt.Rows[0]["Color"].ToString(); Co.barcode = dt.Rows[0]["barcode"].ToString(); Co.price = int.Parse(dt.Rows[0]["Price"].ToString()); #region 花車折扣 //20150612如果為花車商品,直接對原價折價,不走折扣活動 //bool hasStoreFloatDiscount = false; try { XmlDocument doc = new XmlDocument(); doc.Load(HttpContext.Current.Server.MapPath("StoreFloats.xml")); XmlNode discountNode = doc.SelectSingleNode("Discount"); XmlElement element = (XmlElement)discountNode; int DiscountRate = int.Parse(element.GetAttribute("Rate")); XmlNodeList SerialList = doc.DocumentElement.SelectNodes("/Discount/SerialID"); foreach (XmlNode node in SerialList) { string SerialID = node.InnerText; if (Co.SerialId.ToUpper() == SerialID.ToUpper()) { //打折 int DiscountPrice = Convert.ToInt32(Math.Floor((double)Co.price * DiscountRate / 100)); Co.price = DiscountPrice; Co.IsStoreFloat = true; break; } } } catch (Exception e) { string a = e.ToString(); } if (Co.IsStoreFloat == true) { return(Co); } #endregion #region 折扣判斷 DataTable ActivityDT = Activity.GetActivityToday(); if (ActivityDT.Rows.Count > 0) { foreach (DataRow row in ActivityDT.Rows) { string ActivityProductType = row["ActivityProductType"].ToString(); string ActivityID = row["ActivityID"].ToString(); DataTable SerialIdDT = Activity.GetSerialID(ActivityID); if (SerialIdDT.Rows.Count == 0) { //沒有明細,全部符合折扣 //新品折N元一定要有明細才會生效 if (bool.Parse(row["VIPOnly"].ToString())) { Co.VIPDiscountType = row["Type"].ToString(); Co.VIPDiscountParam = row["Parameters"].ToString(); } else { Co.DiscountType = row["Type"].ToString(); Co.DiscountParam = row["Parameters"].ToString(); } } else { //有明細,需判斷1.此商品是否有在明細中,2.是包含還是排除 IEnumerable <DataRow> query = (from a in SerialIdDT.AsEnumerable() where a["ProductSerialID"].ToString().ToUpper() == Co.SerialId.ToUpper() select a).ToList(); if (ActivityProductType == "1" && query.Count() > 0 || ActivityProductType == "0" && query.Count() == 0) { if (row["Type"].ToString() == "新品折X元") { List <ParamData> ParamList = JsonConvert.DeserializeObject <List <ParamData> >(row["Parameters"].ToString()); Co.price -= ParamList[0].Discount; } else { if (bool.Parse(row["VIPOnly"].ToString())) { Co.VIPDiscountType = row["Type"].ToString(); Co.VIPDiscountParam = row["Parameters"].ToString(); } else { Co.DiscountType = row["Type"].ToString(); Co.DiscountParam = row["Parameters"].ToString(); } } } } } } #endregion if (Co.price > 5000) { Co.price = 0; } } return(Co); }