public Int64 Insert(orderproducts objorderproducts) { Int64 result = 0; try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "orderproducts_Insert"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; SqlParameter param = new SqlParameter(); param.ParameterName = "@opid"; param.Value = objorderproducts.opid; param.SqlDbType = SqlDbType.BigInt; param.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(param); cmd.Parameters.AddWithValue("@oid", objorderproducts.oid); cmd.Parameters.AddWithValue("@uid", objorderproducts.uid); cmd.Parameters.AddWithValue("@pid", objorderproducts.pid); cmd.Parameters.AddWithValue("@brandid", objorderproducts.brandid); cmd.Parameters.AddWithValue("@sizeid", objorderproducts.sizeid); cmd.Parameters.AddWithValue("@colorid", objorderproducts.colorid); cmd.Parameters.AddWithValue("@cart", objorderproducts.cart); cmd.Parameters.AddWithValue("@pack", objorderproducts.pack); cmd.Parameters.AddWithValue("@qty", objorderproducts.qty); cmd.Parameters.AddWithValue("@mrp", objorderproducts.mrp); cmd.Parameters.AddWithValue("@unitRate", objorderproducts.unitRate); cmd.Parameters.AddWithValue("@subTotal", objorderproducts.subTotal); cmd.Parameters.AddWithValue("@discount", objorderproducts.discount); cmd.Parameters.AddWithValue("@scheme", objorderproducts.scheme); cmd.Parameters.AddWithValue("@taxableamt", objorderproducts.taxableamt); cmd.Parameters.AddWithValue("@CGSTper", objorderproducts.CGSTper); cmd.Parameters.AddWithValue("@SGSTper", objorderproducts.SGSTper); cmd.Parameters.AddWithValue("@IGSTper", objorderproducts.IGSTper); cmd.Parameters.AddWithValue("@GSTamt", objorderproducts.GSTamt); cmd.Parameters.AddWithValue("@TotalAmount", objorderproducts.TotalAmount); ConnectionString.Open(); cmd.ExecuteNonQuery(); result = Convert.ToInt64(param.Value); } catch (Exception ex) { ErrHandler.writeError(ex.Message, ex.StackTrace); return(result); } finally { ConnectionString.Close(); } return(result); }
public orderproducts SelectById(Int64 opid) { SqlDataAdapter da; DataSet ds = new DataSet(); orderproducts objorderproducts = new orderproducts(); try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "orderproducts_SelectById"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; cmd.Parameters.AddWithValue("@opid", opid); ConnectionString.Open(); da = new SqlDataAdapter(cmd); da.Fill(ds); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0] != null) { if (ds.Tables[0].Rows.Count > 0) { { objorderproducts.opid = Convert.ToInt64(ds.Tables[0].Rows[0]["opid"]); objorderproducts.oid = Convert.ToInt64(ds.Tables[0].Rows[0]["oid"]); objorderproducts.uid = Convert.ToInt64(ds.Tables[0].Rows[0]["uid"]); objorderproducts.pid = Convert.ToInt64(ds.Tables[0].Rows[0]["pid"]); objorderproducts.productprice = Convert.ToDecimal(ds.Tables[0].Rows[0]["productprice"]); objorderproducts.gst = Convert.ToDecimal(ds.Tables[0].Rows[0]["gst"]); objorderproducts.discount = Convert.ToInt32(ds.Tables[0].Rows[0]["discount"]); objorderproducts.productafterdiscountprice = Convert.ToDecimal(ds.Tables[0].Rows[0]["productafterdiscountprice"]); objorderproducts.quantites = Convert.ToInt32(ds.Tables[0].Rows[0]["quantites"]); objorderproducts.producttotalprice = Convert.ToDecimal(ds.Tables[0].Rows[0]["producttotalprice"]); } } } } } } catch (Exception ex) { ErrHandler.writeError(ex.Message, ex.StackTrace); return(null); } finally { ConnectionString.Close(); } return(objorderproducts); }
public Int64 Update(orderproducts objorderproducts) { Int64 result = 0; try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "orderproducts_Update"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; SqlParameter param = new SqlParameter(); param.ParameterName = "@opid"; param.Value = objorderproducts.opid; param.SqlDbType = SqlDbType.BigInt; param.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(param); cmd.Parameters.AddWithValue("@oid", objorderproducts.oid); cmd.Parameters.AddWithValue("@uid", objorderproducts.uid); cmd.Parameters.AddWithValue("@pid", objorderproducts.pid); cmd.Parameters.AddWithValue("@productprice", objorderproducts.productprice); cmd.Parameters.AddWithValue("@gst", objorderproducts.gst); cmd.Parameters.AddWithValue("@discount", objorderproducts.discount); cmd.Parameters.AddWithValue("@productafterdiscountprice", objorderproducts.discount); cmd.Parameters.AddWithValue("@quantites", objorderproducts.quantites); ConnectionString.Open(); cmd.ExecuteNonQuery(); result = Convert.ToInt64(param.Value); } catch (Exception ex) { ErrHandler.writeError(ex.Message, ex.StackTrace); return(result); } finally { ConnectionString.Close(); } return(result); }
protected void lnkConfirmedOrder_Click(object sender, EventArgs e) { LinkButton lnkConfirmedOrder = (LinkButton)sender; RepeaterItem item = (RepeaterItem)lnkConfirmedOrder.NamingContainer; Int64 OrderId_old = Convert.ToInt64(lnkConfirmedOrder.CommandArgument); int tt = 0; Int64 OrderId = 0; try { con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "getCustomer_orderDetails"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@oid", OrderId_old); cmd.Connection = con; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { string finalResult = string.Empty; orders objorders = new orders(); if (ds.Tables[0].Rows[0]["uid"].ToString().Trim() == string.Empty) { objorders.uid = 0; } else { objorders.uid = Convert.ToInt64(ds.Tables[0].Rows[0]["uid"].ToString().Trim()); } if (ds.Tables[0].Rows[0]["productquantites"].ToString().Trim() == string.Empty) { objorders.productquantites = 0; } else { objorders.productquantites = Convert.ToInt32(ds.Tables[0].Rows[0]["productquantites"].ToString().Trim()); } if (ds.Tables[0].Rows[0]["billpaidornot"].ToString().Trim() == string.Empty) { objorders.billpaidornot = false; } else { objorders.billpaidornot = false; } if (ds.Tables[0].Rows[0]["amount"].ToString().Trim() == string.Empty) { objorders.amount = 0; } else { objorders.amount = Convert.ToDecimal(ds.Tables[0].Rows[0]["amount"].ToString().Trim()); } if (ds.Tables[0].Rows[0]["discount"].ToString().Trim() == string.Empty) { objorders.discount = 0; } else { objorders.discount = Convert.ToDecimal(ds.Tables[0].Rows[0]["discount"].ToString().Trim()); } if (ds.Tables[0].Rows[0]["tax"].ToString().Trim() == string.Empty) { objorders.tax = 0; } else { objorders.tax = Convert.ToDecimal(ds.Tables[0].Rows[0]["tax"].ToString().Trim()); } if (ds.Tables[0].Rows[0]["totalamount"].ToString().Trim() == string.Empty) { objorders.totalamount = 0; } else { objorders.totalamount = Convert.ToDecimal(ds.Tables[0].Rows[0]["totalamount"].ToString().Trim()); } if (ds.Tables[0].Rows[0]["orderdate"].ToString().Trim() == string.Empty) { objorders.orderdate = DateTime.Now; } else { objorders.orderdate = DateTime.Now; } if (ds.Tables[0].Rows[0]["UserType"].ToString().Trim() == string.Empty) { objorders.usertype = "U"; } else { objorders.usertype = ds.Tables[0].Rows[0]["UserType"].ToString().Trim(); } Int64 OrderProductAdd = 0; if (ds.Tables[1] != null) { if (ds.Tables[1].Rows.Count > 0) { OrderId = (new Cls_orders_b().Insert(objorders)); if (OrderId > 0) { for (int i = 0; i < ds.Tables[1].Rows.Count; i++) { OrderProductAdd = 0; orderproducts objorderproducts = new orderproducts(); objorderproducts.oid = OrderId; objorderproducts.uid = Convert.ToInt64(ds.Tables[1].Rows[i]["uid"]); objorderproducts.pid = Convert.ToInt64(ds.Tables[1].Rows[i]["pid"]); objorderproducts.productprice = Convert.ToDecimal(ds.Tables[1].Rows[i]["productprice"]); objorderproducts.discount = Convert.ToDecimal(ds.Tables[1].Rows[i]["discount"]); objorderproducts.productafterdiscountprice = Convert.ToDecimal(ds.Tables[1].Rows[i]["productafterdiscountprice"]); objorderproducts.quantites = Convert.ToInt32(ds.Tables[1].Rows[i]["quantites"]); objorderproducts.gst = Convert.ToDecimal(ds.Tables[1].Rows[i]["gst"]); OrderProductAdd = (new Cls_orderproducts_b().Insert(objorderproducts)); #region " Stock Update " Product_StockUpdate(objorderproducts.pid, objorderproducts.quantites); #endregion " Stock Update " } } } } //****************** string s_update = "update Customer_orders set isCreateInvoice=1,ConfirmedInvoiceId='" + OrderId + "' where oid=" + OrderId_old; SqlCommand cmd_update = new SqlCommand(s_update, con); tt = cmd_update.ExecuteNonQuery(); //-------------------------- } } catch { } finally { con.Close(); } spnMessage.Visible = true; if (tt > 0) { spnMessage.Style.Add("color", "green"); spnMessage.InnerText = "Order Confirmed Successfully"; SelectAll(); } else { spnMessage.Style.Add("color", "green"); spnMessage.InnerText = "Order Not Deleted"; } }
public async Task UpdateAsync(orderproducts obj) { _context.orderproducts.Update(obj); await _context.SaveChangesAsync(); }
public async Task CreateAsync(orderproducts obj) { await _context.orderproducts.AddAsync(obj); await _context.SaveChangesAsync(); }
public async Task <IActionResult> OrderInsertandOrderProduct(int customerid, decimal totalamount, string OrderProducts_JSONString, string promocode, string storedid, string discount, string orderstatus, string paymenttype, string paymentstatus, string deliveryaddress, string transactionid, string instruction, string customerdeliverylatitude, string customerdeliverylongitude) { var paramter = new DynamicParameters(); paramter.Add("@customerid", customerid); var orderlist = _ISP_Call.List <orderselectallViewModel>("checkCustomerOrderComplete", paramter); bool flg = true; foreach (var item in orderlist) { if (item.orderstatus == "completedorders" || item.orderstatus == "cancelledorders") { } else { flg = false; } } if (flg == false) { string myJson = "{'message': 'First Complete your Previous Orders'}"; return(Ok(myJson)); } else { //var customer = CustomerRegistrationservices.GetById(id); if (customerid == 0) { return(NotFound()); } else { orders objorders = new orders(); objorders.customerid = customerid; objorders.amount = totalamount; //objorders.placedate = DateTime.UtcNow; objorders.placedate = DateTime.Now; objorders.paymentstatus = paymentstatus; objorders.orderstatus = orderstatus; objorders.discount = Convert.ToDecimal(discount); objorders.storeid = storedid; objorders.deliveryaddress = deliveryaddress; objorders.paymenttype = paymenttype; objorders.promocode = promocode; objorders.transactionid = transactionid; objorders.instructions = instruction; // objorders.propmocode = promocode; objorders.customerdeliverylatitude = customerdeliverylatitude; objorders.customerdeliverylongitude = customerdeliverylongitude; // , deliveryboyid, paymentstatus, orderstatus, isdeleted, discount, storeid, //deliveryaddress, paymenttype, promocode objorders.storeid = storedid; //if (promocode == ""|| storedid=="") //{ // objorders.discount = 0; //} //else //{ // objorders.discount = _storedetailsServices.GetAll().Where(x => x.storeid == storedid&&x.promocode==promocode).FirstOrDefault().discount; //} int OrderProductAdd = 0; int OrderId = 0; var dtOrderProducts = JsonConvert.DeserializeObject <DataTable>(OrderProducts_JSONString); if (dtOrderProducts != null) { if (dtOrderProducts.Rows.Count > 0) { OrderId = await _ordersServices.CreateAsync(objorders); if (OrderId > 0) { for (int i = 0; i < dtOrderProducts.Rows.Count; i++) { orderproducts objorderproduct = new orderproducts(); objorderproduct.oid = OrderId; objorderproduct.pid = Convert.ToInt32(dtOrderProducts.Rows[i]["productid"]); objorderproduct.qty = Convert.ToInt64(dtOrderProducts.Rows[i]["quantites"]); objorderproduct.price = Convert.ToInt64(dtOrderProducts.Rows[i]["productprice"]); objorderproduct.isdeleted = false; await _orderproductServices.CreateAsync(objorderproduct); //id, oid, placedate, orderstatus // id, oid, pid, qty, price, isdeleted //[{"productid":"1","productprice":"500","quantites":10},{"productid":"2","productprice":"500","quantites":10}] } } orderhistory objorderhistory = new orderhistory(); objorderhistory.oid = OrderId; objorderhistory.placedate = DateTime.UtcNow; objorderhistory.orderstatus = "place Order"; await _orderhistoryServices.CreateAsync(objorderhistory); var users = await _usermanager.FindByIdAsync(storedid); string storeDeviceId = users.deviceid; if (storeDeviceId == null || storeDeviceId.ToString().Trim() == "") { } else { string sResponseFromServer = string.Empty, finalResult = string.Empty; try { WebRequest tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send"); tRequest.Method = "post"; //serverKey - Key from Firebase cloud messaging server customer //tRequest.Headers.Add(string.Format("Authorization: key={0}", "AAAAxJW0hf8:APA91bG1ipIsec--9KYV5bv6kagmly4PfFHH-UCLsbsqVxuZsoBPvw-AuRy_DhBa0sT2raF5D0DJhbx8G59lKV2fg6WbUDMzvWsyqxlQLjz-Epk3p04lujWk1c-enH5o3CLq_ejPVqr4")); //store change 9.9.20 //tRequest.Headers.Add(string.Format("Authorization: key={0}", "AAAAr0cwgUE:APA91bEs5PB48LpheJuGQOJi8jENylDdtBgGA5tcHFY2Kbz4-FwNLocAN8z7X7c4ADuP6vA7MSE3M6hx5OHp12iFt0yb7zfHO16c7mlgnppsEOFY8J4WRfpOUI-RkbXBLBwMqYwwDyYX")); ////Sender Id - From firebase project setting //tRequest.Headers.Add(string.Format("Sender: id={0}", "752813637953")); tRequest.Headers.Add(string.Format("Authorization: key={0}", "AAAA-grvO4U:APA91bG1TeBl5uVNLOHGyjSYSJ_-PZiOFKeSUkjhx4do27iECafs1dVdAyhE6-QvMDON6xrz-YOa10tMgFdmy_w1amPXVHsXLWrAggDh8oU0c1F8CvdBW6aGc1wrqP8OlQ86ZzxzkTuS")); //Sender Id - From firebase project setting tRequest.Headers.Add(string.Format("Sender: id={0}", "1073925274501")); tRequest.ContentType = "application/json"; var payload = new { to = storeDeviceId, priority = "high", content_available = true, notification = new { //body = "New Order No. - " + OrderId + " insert", body = "Order Received", title = "New Order", badge = 1 }, data = new { key1 = "AAAA-grvO4U:APA91bG1TeBl5uVNLOHGyjSYSJ_-PZiOFKeSUkjhx4do27iECafs1dVdAyhE6-QvMDON6xrz-YOa10tMgFdmy_w1amPXVHsXLWrAggDh8oU0c1F8CvdBW6aGc1wrqP8OlQ86ZzxzkTuS", key2 = "1073925274501" } }; //string postbody = JsonConvert.SerializeObject(payload).ToString(); var serializer = new JavaScriptSerializer(); var postbody = serializer.Serialize(payload); Byte[] byteArray = Encoding.UTF8.GetBytes(postbody); tRequest.ContentLength = byteArray.Length; using (Stream dataStream = tRequest.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); using (WebResponse tResponse = tRequest.GetResponse()) { using (Stream dataStreamResponse = tResponse.GetResponseStream()) { if (dataStreamResponse != null) { using (StreamReader tReader = new StreamReader(dataStreamResponse)) { sResponseFromServer = tReader.ReadToEnd(); //result.Response = sResponseFromServer; } } } } } } catch (Exception ex) { string s = ex.Message; // throw ex; } // return Ok(sResponseFromServer); } //---sent notification to admin---------------- var users1 = await _usermanager.FindByIdAsync("6852cc0f-f62e-42a4-8dc7-5fd0478ba197"); string deviceid1 = users1.deviceid; fcmNotification obj = new fcmNotification(); obj.adminNotification(deviceid1, "Order Received", "", "New Order"); //manager Notification var paramterManager = new DynamicParameters(); paramterManager.Add("@storeid", storedid); var managerList = _ISP_Call.List <GetManagerList>("GetManagerList", paramterManager); foreach (var item in managerList) { if (item.deviceid == null || item.deviceid.ToString().Trim() == "") { obj.adminNotification(item.deviceid, "Order Received", "", "New Order"); } } } } if (OrderId == 0) { return(BadRequest()); } else { var orders = _ordersServices.GetById(OrderId); return(Ok(orders)); } // customerid, amount, placedate, deliveryboyid, paymentstatus, orderstatus, isdeleted, isactive //customer.deviceid = deviceId; //await CustomerRegistrationservices.UpdateAsync(customer); //if (id < 0) //{ // return BadRequest(); //} //else //{ // return Ok(customer); //} } return(BadRequest()); } }
public orderproducts SelectById(Int64 opid) { SqlDataAdapter da; DataSet ds = new DataSet(); orderproducts objorderproducts = new orderproducts(); try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "orderproducts_SelectById"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; cmd.Parameters.AddWithValue("@opid", opid); ConnectionString.Open(); da = new SqlDataAdapter(cmd); da.Fill(ds); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0] != null) { if (ds.Tables[0].Rows.Count > 0) { { objorderproducts.opid = Convert.ToInt64(ds.Tables[0].Rows[0]["opid"]); objorderproducts.oid = Convert.ToInt64(ds.Tables[0].Rows[0]["oid"]); objorderproducts.uid = Convert.ToInt64(ds.Tables[0].Rows[0]["uid"]); objorderproducts.pid = Convert.ToInt64(ds.Tables[0].Rows[0]["pid"]); objorderproducts.brandid = Convert.ToString(ds.Tables[0].Rows[0]["brandid"]); objorderproducts.sizeid = Convert.ToString(ds.Tables[0].Rows[0]["sizeid"]); objorderproducts.colorid = Convert.ToString(ds.Tables[0].Rows[0]["colorid"]); objorderproducts.cart = Convert.ToDecimal(ds.Tables[0].Rows[0]["cart"]); objorderproducts.pack = Convert.ToString(ds.Tables[0].Rows[0]["pack"]); objorderproducts.qty = Convert.ToDecimal(ds.Tables[0].Rows[0]["qty"]); objorderproducts.mrp = Convert.ToDecimal(ds.Tables[0].Rows[0]["mrp"]); objorderproducts.unitRate = Convert.ToDecimal(ds.Tables[0].Rows[0]["unitRate"]); objorderproducts.subTotal = Convert.ToDecimal(ds.Tables[0].Rows[0]["subTotal"]); objorderproducts.discount = Convert.ToDecimal(ds.Tables[0].Rows[0]["discount"]); objorderproducts.scheme = Convert.ToDecimal(ds.Tables[0].Rows[0]["scheme"]); objorderproducts.taxableamt = Convert.ToDecimal(ds.Tables[0].Rows[0]["taxableamt"]); objorderproducts.CGSTper = Convert.ToDecimal(ds.Tables[0].Rows[0]["CGSTper"]); objorderproducts.SGSTper = Convert.ToDecimal(ds.Tables[0].Rows[0]["SGSTper"]); objorderproducts.IGSTper = Convert.ToDecimal(ds.Tables[0].Rows[0]["IGSTper"]); objorderproducts.GSTamt = Convert.ToDecimal(ds.Tables[0].Rows[0]["GSTamt"]); objorderproducts.TotalAmount = Convert.ToDecimal(ds.Tables[0].Rows[0]["TotalAmount"]); } } } } } } catch (Exception ex) { ErrHandler.writeError(ex.Message, ex.StackTrace); return(null); } finally { ConnectionString.Close(); } return(objorderproducts); }