public static POModel GetCurrency(string currencyCode) { //string currencyName = ""; var poModel = new POModel(); SqlConnection con = new SqlConnection(@"Data Source=WEB3\SHAREPOINT;Initial Catalog=WSS_Search_WEB3;Integrated Security=True"); SqlCommand cmd = new SqlCommand("select PO_NUMBER,PO_STATUS from View_1 where PO_HEADER_ID ='" + currencyCode.ToUpper() + "'", con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { poModel.currencyName = dr["PO_NUMBER"].ToString(); poModel.statusName = dr["PO_STATUS"].ToString(); } dr.Close(); con.Close(); //return currencyName; return(poModel); }
public HttpResponseMessage UpdatePO(POModel pom) { try { bool conn = false; conn = db.Database.Exists(); if (!conn) { ConnectionTools.changeToLocalDB(db); conn = db.Database.Exists(); } if (conn) { var str1 = (from a in db.TBL_PO_PAYMENT where a.PO_ID == pom.PO_ID select a).FirstOrDefault(); //str.BAR_CODE = pom.BAR_CODE; str1.BUSINESS_LOCATION_ID = pom.BUSINESS_LOCATION; str1.COMPANY_ID = pom.COMPANY_ID; str1.DELIVER_ID = pom.DELIVER; str1.DELIVER_TO = pom.DELIVER_TO; str1.DELIVERY_DATE = pom.DELIVERY_DATE; str1.IS_SEND_MAIL = pom.IS_SEND_MAIL; //str.ITEM_NAME = pom.ITEM_NAME; str1.PO_NUMBER = pom.PO_NUMBER1; //str.SEARCH_CODE = pom.SEARCH_CODE; //str.SUPPLIER_EMAIL = pom.SUPPLIER_EMAIL; str1.SUPPLIER_ID = pom.SUPPLIER; str1.TERMS = pom.TERMS; str1.TOTAL_AMOUNT = pom.TOTAL_AMOUNT; str1.TOTAL_TAX = pom.TOTAL_TAX; str1.PO_DATE = DateTime.Now; str1.IS_DELETE = false; //str.SEARCH_STOCK = pom.SearchStock; db.SaveChanges(); long poid = pom.PO_ID; if (pom.SelectedItem.Count > 0) { foreach (var item in pom.SelectedItem) { if (item.TOTAL_QTY != 0) { //if (pom.PO_NUMBER1 != null) //{ // //var str = (from a in db.TBL_PO_ITEMS where a.PO_NUMBER == pom.PO_ID && a.PO_ITEM_ID==item.ITEM_ID && a.PO_QTY !=item.TOTAL_QTY select a).FirstOrDefault(); var str = (from a in db.TBL_PO_ITEMS where a.PO_NUMBER == pom.PO_ID && a.PO_ITEM_ID == item.ITEM_ID select a).FirstOrDefault(); if (str != null) { str.PO_ITEM_ID = item.ITEM_ID; str.PO_NUMBER = Convert.ToInt32(poid); str.PO_DISCOUNT = item.Discount; str.PO_TOTAL_AMOUNT = item.SUB_TOTAL_AFTER_TAX; str.PO_QTY = item.TOTAL_QTY; //PoItem.PO_TAX = item.TotalTax; str.PO_TAX = item.SUB_TOTAL_AFTER_TAX - item.SUB_TOTAL_BEFORE_TAX; //db.TBL_PO_ITEMS.Add(PoItem); db.SaveChanges(); } else { //foreach (var item in pom.SelectedItem) //{ // if (item.TOTAL_QTY != 0) // { TBL_PO_ITEMS PoItem = new TBL_PO_ITEMS(); PoItem.PO_ITEM_ID = item.ITEM_ID; PoItem.PO_NUMBER = Convert.ToInt32(poid); PoItem.PO_DISCOUNT = item.Discount; PoItem.PO_TOTAL_AMOUNT = item.SUB_TOTAL_AFTER_TAX; PoItem.PO_QTY = item.TOTAL_QTY; //PoItem.PO_TAX = item.TotalTax; PoItem.PO_TAX = item.SUB_TOTAL_AFTER_TAX - item.SUB_TOTAL_BEFORE_TAX; db.TBL_PO_ITEMS.Add(PoItem); db.SaveChanges(); // } //} } } } } return(Request.CreateResponse(HttpStatusCode.OK, "Updated success..")); } else { return(Request.CreateResponse(HttpStatusCode.ExpectationFailed)); } } catch (Exception ex) { throw; } finally { ConnectionTools.ChangeToRemoteDB(db); } }
public ActionResult POCreate(POModel poModel) { return(View(poModel)); }
public HttpResponseMessage PurchaseOrdAdd(POModel pom) { try { bool conn = false; conn = db.Database.Exists(); if (!conn) { ConnectionTools.changeToLocalDB(db); conn = db.Database.Exists(); } if (conn) { //TBL_PO po = new TBL_PO(); //po.BAR_CODE = pom.BAR_CODE; //po.BUSINESS_LOCATION_ID = pom.BUSINESS_LOCATION; //po.COMPANY_ID = pom.COMPANY_ID; //po.DELIVER_ID = pom.DELIVER; //po.DELIVER_TO = pom.DELIVER_TO; //// po.DELIVERY_DATE = pom.DELIVERY_DATE; //po.DELIVERY_DATE = DateTime.Now; //po.IS_SEND_MAIL = pom.IS_SEND_MAIL; //po.ITEM_NAME = pom.ITEM_NAME; //po.PO_NUMBER = pom.PO_NUMBER; //po.SEARCH_CODE = pom.SEARCH_CODE; //po.SUPPLIER_EMAIL = pom.SUPPLIER_EMAIL; //po.SUPPLIER_ID = pom.SUPPLIER; //po.TERMS = pom.TERMS; //po.TOTAL_AMOUNT = pom.TOTAL_AMOUNT; //po.TOTAL_TAX = pom.TOTAL_TAX; //po.IS_DELETE = false; //po.PO_DATE = DateTime.Now; //po.SEARCH_STOCK = pom.SearchStock; //db.TBL_PO.Add(po); //db.SaveChanges(); TBL_PO_PAYMENT po = new TBL_PO_PAYMENT(); //po.BAR_CODE = pom.BAR_CODE; po.BUSINESS_LOCATION = pom.BUSINESS_LOCATION; po.COMPANY_ID = pom.COMPANY_ID; po.DELIVER_ID = pom.DELIVER; po.DELIVER_TO = pom.DELIVER_TO; // po.DELIVERY_DATE = pom.DELIVERY_DATE; po.DELIVERY_DATE = DateTime.Now; po.IS_SEND_MAIL = pom.IS_SEND_MAIL; //po.ITEM_NAME = pom.ITEM_NAME; po.PO_NUMBER = pom.PO_NUMBER1; //po.SEARCH_CODE = pom.SEARCH_CODE; po.SUPPLIER_MAIL = pom.SUPPLIER_EMAIL; po.SUPPLIER_NAME = pom.SUPPLIER; po.TERMS = pom.TERMS; po.TOTAL_AMOUNT = pom.TOTAL_AMOUNT; po.TOTAL_TAX = pom.TOTAL_TAX; po.PO_STATUS = pom.PO_STATUS; po.IS_DELETE = false; po.PO_DATE = DateTime.Now; //po.SEARCH_STOCK = pom.SearchStock; db.TBL_PO_PAYMENT.Add(po); db.SaveChanges(); long poid = po.PO_ID; if (pom.SelectedItem.Count > 0) { foreach (var item in pom.SelectedItem) { if (item.TOTAL_QTY != null || item.TOTAL_QTY != 0) { TBL_PO_ITEMS PoItem = new TBL_PO_ITEMS(); PoItem.PO_ITEM_ID = item.ITEM_ID; PoItem.PO_NUMBER = Convert.ToInt32(poid); PoItem.PO_DISCOUNT = item.Discount; PoItem.PO_TOTAL_AMOUNT = item.SUB_TOTAL_AFTER_TAX; PoItem.PO_QTY = item.TOTAL_QTY; //PoItem.PO_TAX = item.TotalTax; PoItem.PO_TAX = item.SUB_TOTAL_AFTER_TAX - item.SUB_TOTAL_BEFORE_TAX; db.TBL_PO_ITEMS.Add(PoItem); db.SaveChanges(); } } } return(Request.CreateResponse(HttpStatusCode.OK, "success")); } else { return(Request.CreateResponse(HttpStatusCode.ExpectationFailed)); } } catch (Exception ex) { throw; } finally { ConnectionTools.ChangeToRemoteDB(db); } }