public static List <DetailsContract> GetDetailsContracts(List <Order> listOrder) { List <DetailsContract> detailsList = new List <DetailsContract>(); DetailsContract dc; foreach (Order item in listOrder) { dc = new DetailsContract(); dc.id_order = item.id_order; Product pr = new CustomManager.Product(); if (MyGlobalClass.DBManager.LoadProductbyID(item.product_id, ref pr).Equals(KEY_VALUES.OK)) { dc.Product = pr.Product_Name_RU; } Region region_sending = new Region(); if (MyGlobalClass.DBManager.LoadRegionbyID(item.region_sending_id, ref region_sending).Equals(KEY_VALUES.OK)) { dc.Region_sending = region_sending.Region_Name; } Region region_origin = new Region(); if (MyGlobalClass.DBManager.LoadRegionbyID(item.region_origin_id, ref region_origin).Equals(KEY_VALUES.OK)) { dc.Region_sending = region_origin.Region_Name; } dc.Order_count = item.Order_Count; dc.Price = CalculatePrice(item); detailsList.Add(dc); } return(detailsList); }
public static string CalculatePrice(Order order) { string answerString = string.Empty; Product product = new CustomManager.Product(); Region region_sending = new Region(); Region region_origin = new Region(); FEACN feacn = new FEACN(); if (!MyGlobalClass.DBManager.LoadProductbyID(order.product_id, ref product).Equals(KEY_VALUES.OK)) { answerString = "This is not calculate"; return(answerString); } if (!MyGlobalClass.DBManager.LoadRegionbyID(order.region_sending_id, ref region_sending).Equals(KEY_VALUES.OK)) { answerString = "This is not calculate"; return(answerString); } if (!MyGlobalClass.DBManager.LoadRegionbyID(order.region_origin_id, ref region_origin).Equals(KEY_VALUES.OK)) { answerString = "This is not calculate"; return(answerString); } if (!MyGlobalClass.DBManager.LoadFEACNbyID(product.feacn_id, ref feacn).Equals(KEY_VALUES.OK)) { answerString = "This is not calculate"; return(answerString); } double aksizMoney = product.Minimum_Cost * feacn.Aksiz_persent / 100; double poshlinaMoney = product.Minimum_Cost * feacn.Poshlina_persent / 100; double qqsMoney = (product.Minimum_Cost + aksizMoney + poshlinaMoney) * feacn.QQS_persent / 100; if (region_sending.Bonus_persent == 0) { poshlinaMoney *= 2; } double summa = (product.Minimum_Cost + poshlinaMoney + aksizMoney) * feacn.Poshlina_persent / 100 + product.Minimum_Cost; return((summa * order.Order_Count).ToString()); }
public static List <AddContractView> GetViewList(List <Order> listOrder) { List <AddContractView> list = new List <AddContractView>(); string url = string.Empty; foreach (Order item in listOrder) { AddContractView view = new AddContractView(); Product product = new CustomManager.Product(); string answer = MyGlobalClass.DBManager.LoadProductbyID(item.product_id, ref product); if (!answer.Equals(KEY_VALUES.OK)) { MessageBox.Show(answer, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { view.Product = product.Product_Name_RU; view.product_id = item.product_id; } Region region_sending = new Region(); answer = MyGlobalClass.DBManager.LoadRegionbyID(item.region_sending_id, ref region_sending); if (!answer.Equals(KEY_VALUES.OK)) { MessageBox.Show(answer, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { view.Region_Sending = region_sending.Region_Name; } Region region_origin = new Region(); answer = MyGlobalClass.DBManager.LoadRegionbyID(item.region_origin_id, ref region_origin); if (!answer.Equals(KEY_VALUES.OK)) { MessageBox.Show(answer, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { view.Region_Origin = region_origin.Region_Name; } view.Order_Count = item.Order_Count; Location location = new CustomManager.Location(); answer = MyGlobalClass.DBManager.LoadLocationbyID(item.location_id, ref location); if (!answer.Equals(KEY_VALUES.OK)) { //MessageBox.Show(answer, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { view.Location = string.Format("Lat={0}; Lon={1}", location.Latitude, location.Longitude); view.location_id = item.location_id; } list.Add(view); } return(list); }