public void getStore() { try { ckon.sqlCon().Open(); String cmd = "SELECT * FROM store"; ckon.sqlDataRd = sql.ExecuteDataReader(cmd, ckon.sqlCon()); if (ckon.sqlDataRd.HasRows) { while (ckon.sqlDataRd.Read()) { storeCode = Convert.ToString(ckon.sqlDataRd["CODE"]); regional = Convert.ToString(ckon.sqlDataRd["REGIONAL"]); city = Convert.ToString(ckon.sqlDataRd["CITY"]); } } } catch (Exception e) { MessageBox.Show(e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (ckon.sqlDataRd != null) { ckon.sqlDataRd.Close(); } if (ckon.sqlCon().State == ConnectionState.Open) { ckon.sqlCon().Close(); } } }
public async Task <Boolean> returnOrder() { bool isSuccess = false; try { List <ReturnOrderLine> ro_LineList = new List <ReturnOrderLine>(); link_api = link.aLink; ckon.sqlCon().Open(); String cmd = "SELECT a.RETURN_ORDER_ID, a._id as RoId, a.STORE_CODE, a.DATE, a.REMARK, a.STATUS, a.TIME, a.TIME_STAMP, a.TOTAL_QTY, " + "a.WAREHOUSE_ID, a.EMPLOYEE_ID, a.EMPLOYEE_NAME, a.NO_SJ, c._id as ArtId, c.ARTICLE_ID, c.ARTICLE_NAME, c.ARTICLE_ID_ALIAS, c.PRICE, c.UNIT, " + "b._id as RoLineId, b.QUANTITY FROM returnorder a INNER JOIN returnorder_line b " + "ON a.RETURN_ORDER_ID = b.RETURN_ORDER_ID INNER JOIN article c " + "ON b.ARTICLE_ID = c.ARTICLE_ID WHERE a.STATUS_API = 0"; ckon.sqlDataRd = sql.ExecuteDataReader(cmd, ckon.sqlCon()); if (ckon.sqlDataRd.HasRows) { while (ckon.sqlDataRd.Read()) { id_r_o2 = Convert.ToString(ckon.sqlDataRd["RETURN_ORDER_ID"]); seq_number_substring = id_r_o2.Substring(12); store_code2 = Convert.ToString(ckon.sqlDataRd["STORE_CODE"]); date2 = Convert.ToString(ckon.sqlDataRd["DATE"]); id_Ro2 = Convert.ToInt32(ckon.sqlDataRd["RoId"]); remark2 = Convert.ToString(ckon.sqlDataRd["REMARK"]); status2 = Convert.ToInt32(ckon.sqlDataRd["STATUS"]); time2 = Convert.ToString(ckon.sqlDataRd["TIME"]); timestamp2 = Convert.ToString(ckon.sqlDataRd["TIME_STAMP"]); totalqty2 = Convert.ToInt32(ckon.sqlDataRd["TOTAL_QTY"]); warehouseid2 = Convert.ToString(ckon.sqlDataRd["WAREHOUSE_ID"]); epy_id = Convert.ToString(ckon.sqlDataRd["EMPLOYEE_ID"]); epy_name = Convert.ToString(ckon.sqlDataRd["EMPLOYEE_NAME"]); no_sj = Convert.ToString(ckon.sqlDataRd["NO_SJ"]); id_article2 = Convert.ToInt32(ckon.sqlDataRd["ArtId"]); id_from_article2 = Convert.ToString(ckon.sqlDataRd["ARTICLE_ID"]); articleName2 = Convert.ToString(ckon.sqlDataRd["ARTICLE_NAME"]); unit2 = Convert.ToString(ckon.sqlDataRd["UNIT"]); price_article2 = Convert.ToInt32(ckon.sqlDataRd["PRICE"]); art_id_alias = Convert.ToString(ckon.sqlDataRd["ARTICLE_ID_ALIAS"]); id_article_Fk2 = id_article2; id_RO_Line2 = Convert.ToInt32(ckon.sqlDataRd["RoLineId"]); qty2 = Convert.ToInt32(ckon.sqlDataRd["QUANTITY"]); ReturnOrderLine roLine = new ReturnOrderLine() { article = new Article { articleId = id_from_article2, articleName = articleName2, unit = unit2, id = id_article2, price = price_article2, articleIdAlias = art_id_alias }, articleIdFk = id_article_Fk2, id = id_RO_Line2, quantity = qty2, returnOrderId = Ro_id2, returnOrderIdFk = id_Ro2, unit = unit_ro }; ro_LineList.Add(roLine); } RetrunOrder ro_new = new RetrunOrder() { storeCode = store_code2, sequenceNumber = seq_number_substring, date = date2, id = id_Ro2, remark = remark2, returnOrderId = id_r_o2, returnOrderLines = ro_LineList, status = status2, time = time2, timeStamp = timestamp2, totalQty = totalqty2, warehouseId = warehouseid2, oldSJ = no_sj }; var returnOrder = JsonConvert.SerializeObject(ro_new); var credentials = new NetworkCredential("username", "password"); var handler = new HttpClientHandler { Credentials = credentials }; var httpContent = new StringContent(returnOrder, Encoding.UTF8, "application/json"); using (var client = new HttpClient(handler)) { try { HttpResponseMessage message = client.PostAsync(link_api + "/api/ReturnOrder", httpContent).Result; if (message.IsSuccessStatusCode) { String cmd_update = "UPDATE returnorder SET STATUS_API='1' WHERE RETURN_ORDER_ID='" + id_r_o2 + "'"; CRUD update = new CRUD(); update.ExecuteNonQuery(cmd_update); isSuccess = true; } else { isSuccess = false; MessageBox.Show("Failed! Please try again."); } } catch (Exception ex) { isSuccess = false; MessageBox.Show(ex.ToString()); } } } return(isSuccess); } catch (Exception e) { MessageBox.Show(e.ToString()); return(isSuccess); } }
public async Task <Boolean> deliveryCustPost(string _deliveryCustId) { bool isSuccess = false; try { List <DeliveryCustomerLines> deliveryCustLines = new List <DeliveryCustomerLines>(); link_api = link.aLink; ckon.sqlCon().Open(); String cmd = "SELECT a.DATE, a.TIME, a.TOTAL_QTY, a.EMPLOYEE_ID, a.EMPLOYEE_NAME, a.TRANSACTION_ID, " + "b.ARTICLE_ID, b.COURIER, b.QTY, b.DELIVERYADDRESS, b.DELIVERYTYPE, b.NO_RESI, b.QTY, b.STORE_FROM, b.STORE_TO FROM deliverycustomer a " + "join deliverycustomer_line b on b.DELIVERY_CUST_ID = a.DELIVERY_CUST_ID " + "where a.DELIVERY_CUST_ID = '" + _deliveryCustId + "'"; ckon.sqlDataRd = sql.ExecuteDataReader(cmd, ckon.sqlCon()); if (ckon.sqlDataRd.HasRows) { while (ckon.sqlDataRd.Read()) { date = Convert.ToString(ckon.sqlDataRd["DATE"]); time = Convert.ToString(ckon.sqlDataRd["TIME"]); total_qty = Convert.ToString(ckon.sqlDataRd["TOTAL_QTY"]); empl_Id = Convert.ToString(ckon.sqlDataRd["EMPLOYEE_ID"]); empl_Name = Convert.ToString(ckon.sqlDataRd["EMPLOYEE_NAME"]); transactionId = Convert.ToString(ckon.sqlDataRd["TRANSACTION_ID"]); articleId = Convert.ToString(ckon.sqlDataRd["ARTICLE_ID"]); courier = Convert.ToString(ckon.sqlDataRd["COURIER"]); qty = Convert.ToString(ckon.sqlDataRd["QTY"]); address = Convert.ToString(ckon.sqlDataRd["DELIVERYADDRESS"]); type = Convert.ToString(ckon.sqlDataRd["DELIVERYTYPE"]); noResi = Convert.ToString(ckon.sqlDataRd["NO_RESI"]); storeFrom = Convert.ToString(ckon.sqlDataRd["STORE_FROM"]); storeTo = Convert.ToString(ckon.sqlDataRd["STORE_TO"]); DeliveryCustomerLines deliveryCustomerLines = new DeliveryCustomerLines(); deliveryCustomerLines.DeliveryCustId = _deliveryCustId; deliveryCustomerLines.ArticleId = articleId; deliveryCustomerLines.Qty = Convert.ToInt32(qty); deliveryCustomerLines.StoreFrom = storeFrom; deliveryCustomerLines.StoreTo = storeTo; deliveryCustomerLines.DeliveryAddress = address; deliveryCustomerLines.Courier = courier; deliveryCustomerLines.NoResi = noResi; deliveryCustomerLines.DeliveryType = type; deliveryCustLines.Add(deliveryCustomerLines); } DeliveryCustomer deliveryCustomer = new DeliveryCustomer(); deliveryCustomer.DeliveryCustId = _deliveryCustId; deliveryCustomer.Date = date; deliveryCustomer.Time = time; deliveryCustomer.TotalQty = total_qty; deliveryCustomer.TransactionId = transactionId; deliveryCustomer.EmployeeId = empl_Id; deliveryCustomer.EmployeeName = empl_Name; deliveryCustomer.deliveryCustLines = deliveryCustLines; var mutasiOrder = JsonConvert.SerializeObject(deliveryCustomer); var credentials = new NetworkCredential("username", "password"); var handler = new HttpClientHandler { Credentials = credentials }; var httpContent = new StringContent(mutasiOrder, Encoding.UTF8, "application/json"); using (var client = new HttpClient(handler)) { try { HttpResponseMessage message = client.PostAsync(link_api + "/api/DeliveryCust", httpContent).Result; if (message.IsSuccessStatusCode) { String cmd_update = "UPDATE deliverycustomer SET STATUS_API = '1', STATUS = '1' WHERE DELIVERY_CUST_ID='" + _deliveryCustId + "'"; CRUD update = new CRUD(); update.ExecuteNonQuery(cmd_update); isSuccess = true; } else { isSuccess = false; MessageBox.Show("Failed! Please try again."); } } catch (Exception ex) { isSuccess = false; MessageBox.Show(ex.ToString()); } } } return(isSuccess); } catch (Exception e) { MessageBox.Show(e.ToString()); return(isSuccess); } }
//=============================================================================================== public async Task <Boolean> mutasiOrder() { bool isSuccess = false; try { List <MutasiOrderLine> mo_LinesList = new List <MutasiOrderLine>(); link_api = link.aLink; ckon.sqlCon().Open(); String cmd = "SELECT a.MUTASI_ORDER_ID, a.STORE_CODE, a.DATE, a._id as MoId, a.MUTASI_FROM_WAREHOUSE, a.MUTASI_TO_WAREHOUSE, " + "a.REQUEST_DELIVERY_DATE, a.STATUS, a.TIME, a.TIME_STAMP, a.TOTAL_QTY, a.EMPLOYEE_ID, a.EMPLOYEE_NAME, a.NO_SJ, " + "c._id as ArtId, c.ARTICLE_ID, c.ARTICLE_NAME, c.UNIT, c.PRICE, c.ARTICLE_ID_ALIAS, b._id as MoLineId, b.QUANTITY FROM mutasiorder a INNER JOIN mutasiorder_line b " + "ON a.MUTASI_ORDER_ID = b.MUTASI_ORDER_ID INNER JOIN article c " + "ON c.ARTICLE_ID = b.ARTICLE_ID WHERE a.STATUS_API = 0"; ckon.sqlDataRd = sql.ExecuteDataReader(cmd, ckon.sqlCon()); if (ckon.sqlDataRd.HasRows) { while (ckon.sqlDataRd.Read()) { id_m_o2 = Convert.ToString(ckon.sqlDataRd["MUTASI_ORDER_ID"]); seq_number_substring = id_m_o2.Substring(12); store_code2 = Convert.ToString(ckon.sqlDataRd["STORE_CODE"]); date2 = Convert.ToString(ckon.sqlDataRd["DATE"]); id_Mo2 = Convert.ToInt32(ckon.sqlDataRd["MoId"]); mut_from_war2 = Convert.ToString(ckon.sqlDataRd["MUTASI_FROM_WAREHOUSE"]); mut_to_war2 = Convert.ToString(ckon.sqlDataRd["MUTASI_TO_WAREHOUSE"]); req_dev_date2 = Convert.ToString(ckon.sqlDataRd["REQUEST_DELIVERY_DATE"]); status2 = Convert.ToInt32(ckon.sqlDataRd["STATUS"]); time2 = Convert.ToString(ckon.sqlDataRd["TIME"]); timestamp2 = Convert.ToString(ckon.sqlDataRd["TIME_STAMP"]); totalqty2 = Convert.ToInt32(ckon.sqlDataRd["TOTAL_QTY"]); epy_id = Convert.ToString(ckon.sqlDataRd["EMPLOYEE_ID"]); epy_name = Convert.ToString(ckon.sqlDataRd["EMPLOYEE_NAME"]); no_sj = Convert.ToString(ckon.sqlDataRd["NO_SJ"]); id_article2 = Convert.ToInt32(ckon.sqlDataRd["ArtId"]); id_from_article2 = Convert.ToString(ckon.sqlDataRd["ARTICLE_ID"]); articleName2 = Convert.ToString(ckon.sqlDataRd["ARTICLE_NAME"]); unit2 = Convert.ToString(ckon.sqlDataRd["UNIT"]); price_article2 = Convert.ToInt32(ckon.sqlDataRd["PRICE"]); art_id_alias = Convert.ToString(ckon.sqlDataRd["ARTICLE_ID_ALIAS"]); id_article_Fk2 = id_article2; id_MO_Line2 = Convert.ToInt32(ckon.sqlDataRd["MoLineId"]); qty2 = Convert.ToInt32(ckon.sqlDataRd["QUANTITY"]); MutasiOrderLine mo_line = new MutasiOrderLine() { article = new Article { articleId = id_from_article2, articleName = articleName2, unit = unit2, id = id_article2, price = price_article2, articleIdAlias = art_id_alias }, articleIdFk = id_article_Fk2, id = id_MO_Line2, mutasiOrderId = id_m_o2, mutasiOrderIdFk = id_Mo2, quantity = qty2, unit = unit2 }; mo_LinesList.Add(mo_line); } MutasiOrder mo_new = new MutasiOrder() { storeCode = store_code2, sequenceNumber = seq_number_substring, date = date2, id = id_Mo2, mutasiFromWarehouse = mut_from_war2, mutasiToWarehouse = mut_to_war2, mutasiOrderId = id_m_o2, mutasiOrderLines = mo_LinesList, requestDeliveryDate = req_dev_date2, status = status2, time = time2, timeStamp = timestamp2, totalQty = totalqty2, employeeId = epy_id, employeeName = epy_name, oldSJ = no_sj }; var mutasiOrder = JsonConvert.SerializeObject(mo_new); var credentials = new NetworkCredential("username", "password"); var handler = new HttpClientHandler { Credentials = credentials }; var httpContent = new StringContent(mutasiOrder, Encoding.UTF8, "application/json"); using (var client = new HttpClient(handler)) { try { HttpResponseMessage message = client.PostAsync(link_api + "/api/MutasiOrder", httpContent).Result; if (message.IsSuccessStatusCode) { String cmd_update = "UPDATE mutasiorder SET STATUS_API = '1' WHERE MUTASI_ORDER_ID='" + id_m_o2 + "'"; CRUD update = new CRUD(); update.ExecuteNonQuery(cmd_update); isSuccess = true; } else { isSuccess = false; MessageBox.Show("Failed! Please try again."); } } catch (Exception ex) { isSuccess = false; MessageBox.Show(ex.ToString()); } } } return(isSuccess); } catch (Exception e) { MessageBox.Show(e.ToString()); return(isSuccess); } }