public void InsertBill(Bill bill, Hashtable billdetail) { data.Bills.InsertOnSubmit(bill); data.SubmitChanges(); IEnumerator ie = billdetail.Keys.GetEnumerator(); while (ie.MoveNext()) { BillDetail bd = new BillDetail(); Object obj = ie.Current; bd.IDBill = bill.ID; bd.IDProduct = (int)obj; bd.Number = (int)billdetail[obj]; bd.Price = 0; data.BillDetails.InsertOnSubmit(bd); } data.SubmitChanges(); }
public ActionResult AddRentalPeriod(FormCollection data) { var motelID = int.Parse(data["motelID"]); var fromDayAdd = DateTime.Parse(data["fromDayAdd"]); var toDayAdd = DateTime.Parse(data["toDayAdd"]); var buildDetails = new BillDetail() { BillID = db.Bills.SingleOrDefault(p => p.MotelID == motelID).BillID, BillStatus = false, FromDay = fromDayAdd, ToDay = toDayAdd, RoomRates = db.MotelRooms.SingleOrDefault(p => p.MotelID == motelID).Price }; db.BillDetails.Add(buildDetails); db.SaveChanges(); return(RedirectToAction("RoomDetails", "User", new { motelID = motelID })); }
public List <BillDetail> GetAllBillDetail() { List <BillDetail> listB = new List <BillDetail>(); var resultSet = db.Usp_GetAllBillDetail(); if (resultSet.Count() > 0) { foreach (var u in resultSet) { BillDetail bd = new BillDetail(); bd.Id = u.Id; bd.BillId = u.BillId; bd.FoodId = u.FoodId; bd.Quantity = u.Quantity; } } return(listB); }
public void DeleteBillDetail(IList <BillDetail> billDetailList, User user) { if (billDetailList != null && billDetailList.Count > 0) { IDictionary <string, Bill> cachedBillDic = new Dictionary <string, Bill>(); foreach (BillDetail billDetail in billDetailList) { BillDetail oldBillDetail = this.billDetailMgr.LoadBillDetail(billDetail.Id); Bill bill = oldBillDetail.Bill; #region 缓存Bill if (!cachedBillDic.ContainsKey(bill.BillNo)) { cachedBillDic.Add(bill.BillNo, bill); #region 检查状态 if (bill.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE) { throw new BusinessErrorException("Bill.Error.StatusErrorWhenDeleteDetail", bill.Status, bill.BillNo); } #endregion } #endregion //扣减ActingBill数量和金额 this.actingBillMgr.ReverseUpdateActingBill(oldBillDetail, null, user); this.billDetailMgr.DeleteBillDetail(oldBillDetail); //bill.RemoveBillDetail(oldBillDetail); } #region 更新Bill DateTime dateTimeNow = DateTime.Now; foreach (Bill bill in cachedBillDic.Values) { bill.LastModifyDate = dateTimeNow; bill.LastModifyUser = user; this.UpdateBill(bill); } #endregion } }
/// <summary> /// DeletebillDetail - xoa thông tin billDetail /// </summary> /// <param name="billDetail"></param> /// <returns></returns> public bool DeleteBillDetail(BillDetail billDetail) { SqlParameter[] paramList = new SqlParameter[2]; paramList[0] = new SqlParameter("@BillId", SqlDbType.Int); paramList[0].Value = billDetail.BillId; paramList[1] = new SqlParameter("@ProductId", SqlDbType.Int); paramList[1].Value = billDetail.ProductId; if (db.executeUpdate("DeleteBillDetail", paramList) == 0) { return(false); } else { return(true); } }
public HttpResponseMessage Create(HttpRequestMessage request, BillDetail billdetail) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { var result = billDetailService.Add(billdetail); billDetailService.SaveChanges(); response = request.CreateResponse(HttpStatusCode.Created, result); } return response; })); }
private static void BillDetail() { List.BillDetail.Clear(); foreach (var item in Execute.Read("billdetail")["billdetail"]) { var detail = new BillDetail() { BillID = item["BillID"], ProductID = item["ProductID"], ProductName = item["ProductName"], Count = item["Count"], Price = item["Price"], Sum = item["Sum"] }; List.BillDetail.Add(detail); } }
public void BillDetail() { int count = uow.BillDetails.GetAll().AsQueryable<BillDetail>().Count<BillDetail>(); #region Add BillDetail newEntity = new BillDetail() { AccountCodeID = (int)LookUps.LookUpsValues["AccountCodeID"], Amount = 1, BillHeaderID = (long)LookUps.LookUpsValues["BillHeaderID"], Notes = "Notes" }; uow.BillDetails.Add<BillDetail, long>(newEntity); uow.BillDetails.Commit(); var result = uow.BillDetails.GetAll().AsQueryable<BillDetail>(); Assert.AreEqual(count + 1, result.Count<BillDetail>(), "Adding Error"); #endregion #region Update BillDetail entity = uow.BillDetails.GetById(newEntity.ID); entity.Amount = 2; entity.Notes = "Notes2"; uow.BillDetails.Update(entity); uow.BillDetails.Commit(); BillDetail entity2 = uow.BillDetails.GetById(newEntity.ID); Assert.AreEqual(2, entity2.Amount, "Updating Error"); Assert.AreEqual("Notes2", entity2.Notes, "Updating Error"); #endregion #region Delete BillDetail entityDeleted = uow.BillDetails.GetById(newEntity.ID); uow.BillDetails.Delete(entity2); uow.BillDetails.Commit(); Assert.AreEqual(count, uow.BillDetails.GetAll().AsQueryable<BillDetail>().Count<BillDetail>(), "Deleting Error"); #endregion }
public ActionResult SaveInvoice() { String orderName = Request["order_name"]; String orderEmail = Request["order_email"]; String orderAddress = Request["order_address"]; String orderPhone = Request["order_phone"]; Customer customer = new Customer(orderName, orderAddress, orderEmail, orderPhone); db.Customers.Add(customer); db.SaveChanges(); var countOfRows = db.Customers.ToList().Count(); var lastRowID = db.Customers.OrderBy(c => c.ID).Skip(countOfRows - 1).Take(1).Single().ID; List <Cart> cartList = Session["cart"] as List <Cart>; decimal totalPrice = 0; foreach (var cart in cartList) { totalPrice += cart.totalPrice; } Bill bill = new Bill(lastRowID, totalPrice); db.Bills.Add(bill); db.SaveChanges(); countOfRows = db.Bills.ToList().Count(); lastRowID = db.Bills.OrderBy(c => c.ID).Skip(countOfRows - 1).Take(1).Single().ID; foreach (var cart in cartList) { BillDetail billDetail = new BillDetail(cart.product.ID, cart.totalPrice, lastRowID, cart.quantity); db.BillDetails.Add(billDetail); } db.SaveChanges(); ViewBag.customer = customer; ViewBag.cartList = Session["cart"] as List <Cart>; Session["cart"] = null; return(View("Invoice")); }
public void updateBillDetail(DataGridView lstbilldetail, TextBox txtid) { CMART0Entities db = new CMART0Entities(); List <BillDetail> detail = loadDetailOfBill(txtid.Text); for (int i = 0; i < lstbilldetail.Rows.Count - 1; i++) { int a = 0; for (int m = 0; m < detail.Count; m++) { if (detail[m].ProductID.ToString() == lstbilldetail.Rows[i].Cells["ProductID"].Value.ToString()) { string productid = lstbilldetail.Rows[i].Cells["ProductID"].Value.ToString(); string billid = txtid.Text; BillDetail edit = db.BillDetails.Single(st => st.BillID == billid && st.ProductID == productid); edit.Quantity = (int)lstbilldetail.Rows[i].Cells["Quantity"].Value; edit.Price = float.Parse(lstbilldetail.Rows[i].Cells["Price"].Value.ToString()); db.SaveChanges(); a = 1; } } if (a == 0) { db.usp_BillDetail_Add(txtid.Text, lstbilldetail.Rows[i].Cells["ProductID"].Value.ToString(), (int)lstbilldetail.Rows[i].Cells["Quantity"].Value, (float)lstbilldetail.Rows[i].Cells["Price"].Value); } } for (int i = 0; i < detail.Count; i++) { int b = 0; for (int m = 0; m < lstbilldetail.Rows.Count - 1; m++) { if (lstbilldetail.Rows[m].Cells["ProductID"].Value.Equals(detail[i].ProductID.ToString())) { b = 1; } } if (b == 0) { db.usp_BillDetail_Delete(txtid.Text, detail[i].ProductID); } } }
/// <summary> /// Save a new bill or update bill /// </summary> /// <param name="billViewModel"></param> public void SaveBill(BillViewModel billViewModel) { Bill bill = Mapper.Map <BillViewModel, Bill>(billViewModel); List <BillDetail> BillDetails = new List <BillDetail>(); foreach (var item in billViewModel.BillDetailViewModel) { var BillDetail = new BillDetail() { ColorId = item.ColorId, Price = item.Price, SizeId = item.SizeId, Quantity = item.Quantity, ProductId = item.ProductId }; BillDetails.Add(BillDetail); } bill.BillDetails = BillDetails; _billRepository.Add(bill); }
public async Task <IActionResult> Post([FromBody] BillDetail billDetail) { if (!ModelState.IsValid) { return(ModelError()); } var user = await GetCurrentUser(); billDetail.organizationId = user.OrganizationId; var createResponse = await _billService.CreateBillAsync(billDetail, user.Id); if (!createResponse.IsSuccess) { return(BadRequest(createResponse)); } return(Ok(createResponse)); }
public JsonResult DeleteDetail(BillDetail oBillDetail) { BillDetailService oBillDetailService = new BillDetailService(); BillDetail _oBillDetail = new BillDetail(); try { _oBillDetail = oBillDetail; oBillDetail.ErrorMessage = oBillDetailService.Delete(oBillDetail, (int)Session[GlobalSession.UserID]); } catch (Exception ex) { _oBill = new Bill(); _oBill.ErrorMessage = ex.Message; } JavaScriptSerializer serializer = new JavaScriptSerializer(); string sjson = serializer.Serialize(oBillDetail); return(Json(sjson, JsonRequestBehavior.AllowGet)); }
public List <BillDetail> getlFoods1() { List <BillDetail> lfoo1 = new List <BillDetail>(); DataTable dt = new DataTable(); dt = selectAll(); foreach (DataRow row in dt.Rows) { BillDetail itm1 = new BillDetail(); itm1.bill_detail_id = row[bild.bill_detail_id].ToString(); itm1.order_id = row[bild.order_id].ToString(); itm1.status_void = row[bild.status_void].ToString(); itm1.foods_id = row[bild.foods_id].ToString(); itm1.bill_id = row[bild.bill_id].ToString(); itm1.lot_id = row[bild.lot_id].ToString(); //itm1.foods_cat_id = row[bil.foods_cat_id].ToString(); lfoo1.Add(itm1); } return(lfoo1); }
public ActionResult GetByID(int entryid) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { var data = BillDetail.GetById(entryid, null, false); var ref_Roles = CustomModel.GetActiveStatus(); return(Json(new { success = true, data = data })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { dbConn.Close(); } }
public bool Update(BillDetail entity) { try { var BillDetail = db.BillDetails.Find(entity.BillDetailID); BillDetail.BillDetailID = entity.BillDetailID; BillDetail.BillID = entity.BillID; BillDetail.ProductID = entity.ProductID; BillDetail.Quantity = entity.Quantity; BillDetail.Warranty = entity.Warranty; BillDetail.Total = entity.Total; db.SaveChanges(); return(true); } catch (Exception) { //logging return(false); } }
public String insert(BillDetail p, String userId) { String re = ""; String sql = ""; p.active = "1"; //p.ssdata_id = ""; int chk = 0; chkNull(p); sql = "Insert Into " + bild.table + " set " + " " + bild.bill_id + " = '" + p.bill_id + "'" + "," + bild.order_id + " = '" + p.order_id.Replace("'", "''") + "'" + "," + bild.remark + " = '" + p.remark.Replace("'", "''") + "'" + "," + bild.date_create + " = now()" + "," + bild.active + " = '1'" + "," + bild.user_create + " = '" + userId + "' " + "," + bild.host_id + " = '" + p.host_id + "' " + "," + bild.branch_id + " = '" + p.branch_id + "' " + "," + bild.device_id + " = '" + p.device_id + "' " + "," + bild.foods_id + " = '" + p.foods_id + "' " + "," + bild.price + " = '" + p.price + "' " + "," + bild.foods_code + " = '" + p.foods_code + "' " + "," + bild.status_void + " = '" + p.status_void + "' " + "," + bild.qty + " = '" + p.qty + "' " + "," + bild.amount + " = '" + p.amount + "' " + //"," + bil.foods_cat_id + " = '" + p.foods_cat_id + "' " + //"," + bil.filename + " = '" + p.filename + "' " + " "; try { re = conn.ExecuteNonQuery(conn.conn, sql); } catch (Exception ex) { sql = ex.Message + " " + ex.InnerException; new LogFile("BillDetail -> insert" + ex.Message + " " + ex.InnerException); } return(re); }
//取消申请 private void btnCancel_Click(object sender, EventArgs e) { try { if (dgvMain.SelectedRows.Count != 0) { DisplayPlWailt(); IList <BillDetail> billDetails = new List <BillDetail>(); foreach (DataGridViewRow row in dgvMain.SelectedRows) { BillDetail billDetail = new BillDetail(); billDetail.BillNo = row.Cells["BillNo"].Value.ToString(); billDetail.BillType = row.Cells["@BillType"].Value.ToString(); billDetail.DetailID = Convert.ToInt32(row.Cells["DetailID"].Value); billDetail.Operator = Environment.MachineName; billDetails.Add(billDetail); } BillDetail[] tmp = new BillDetail[billDetails.Count]; billDetails.CopyTo(tmp, 0); Task task = new Task(url); task.CancelCompleted += new Task.CancelCompletedEventHandler(delegate(bool isSuccess, string msg) { if (!isSuccess) { MessageBox.Show(msg); } RefreshData(); }); task.Cancel(tmp, UseTag); } else { MessageBox.Show("请选择要取消的仓库作业。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("取消失败,原因:" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public List <BillDetail> GetBillDetails(int billId) { List <BillDetail> billDetails = new List <BillDetail>(); SqlParameter[] sqlParas = new SqlParameter[1]; sqlParas[0] = new SqlParameter() { ParameterName = "bill_id", Value = billId }; string error = null; DataSet ds = AccessDb.AccessDb.Instance.GetData("EXEC dbo.GetBillDetails @bill_id", sqlParas, ref error); if (ds.Tables.Count > 0) { DataTable dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { BillDetail billDetail = new BillDetail(); billDetail.Bill = new Bill(); billDetail.Bill.Id = (int)dt.Rows[i][0]; billDetail.Bill.PaymentDate = (DateTime)dt.Rows[i][1]; billDetail.Bill.Value = (int)dt.Rows[i][2]; if (dt.Rows[i][3] != DBNull.Value) { billDetail.Bill.Employee = new Employee(); billDetail.Bill.Employee.Id = (int)dt.Rows[i][3]; billDetail.Bill.Employee.Name = dt.Rows[i][4].ToString(); } billDetail.Cake = new Cake(); billDetail.Cake.Name = dt.Rows[i][5].ToString(); billDetail.Cost = (int)dt.Rows[i][6]; billDetail.Amount = (int)dt.Rows[i][7]; billDetails.Add(billDetail); } } return(billDetails); }
public ActionResult RentRoom(int bookingid, int roomid) { var bookinginfo = BookingRoomBLL.Instance.GetBookingbyID(bookingid); var user = ManageBLL.Instance.GetUserByUserName(User.Identity.Name); using (var db = new QLKSWEBEntities()) { Bill bill = new Bill() { CheckinDate = DateTime.Now, BillStatus = "OPEN", CreatedUserID = user.AccountID, DateCreated = DateTime.Now }; db.Bills.Add(bill); if (db.SaveChanges() > 0) { var room = db.Rooms.Find(roomid); room.RoomStatus = "RENTED"; db.SaveChanges(); var booking = db.Bookings.Find(bookingid); booking.BookingStatus = "DONE"; db.SaveChanges(); foreach (var item in bookinginfo.BookingServices) { BillDetail billDetail = new BillDetail() { BillID = bill.BillID, ServicesID = item.ServicesID, RoomID = roomid, Quantity = 1, TotalSerivcesPrices = item.Service.ServicesPrices }; db.BillDetails.Add(billDetail); db.SaveChanges(); } return(RedirectToAction("Manage-19")); } return(RedirectToAction("Manage-19")); } }
/// <summary> /// 解析账单 /// </summary> /// <param name="message"></param> /// <returns></returns> public static Bill AnalyseToBill(byte[] originBytes) { if (originBytes == null || originBytes.Length == 0) { throw new ArgumentNullException("originBytes"); } Bill result = new Bill(); int offset = 0; //head result = ParseFromBytes <Bill>(originBytes, ref offset); //body for (int index = 0; index < result.Count; index++) { BillDetail billDetail = ParseFromBytes <BillDetail>(originBytes, ref offset); result.BillDetails.Add(billDetail); } return(result); }
public async Task <ActionResult <BillDetail> > PostBillDetail(BillDetail billDetail) { _context.BillDetails.Add(billDetail); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (BillDetailExists(billDetail.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetBillDetail", new { id = billDetail.Id }, billDetail)); }
public ActionResult Create(BillDetail item) { IDbConnection db = new OrmliteConnection().openConn(); try { item.entryname = item.entryname ?? ""; item.entrycode = item.entrycode ?? ""; //if (string.IsNullOrEmpty(item.entryname) || string.IsNullOrEmpty(item.entrycode)) return Json(new { success = false, message = tw_Lang.Common_ActionResult_MissingInfo }); var isExist = BillDetail.GetById(item.entryid, null, false); //Validate //insert / update if (item.entryid == 0) { //insert item.createdat = DateTime.Now; item.createdby = currentUser.entryid; item.updatedat = DateTime.Now; item.updatedby = currentUser.entryid; item.isactive = true; } else { //update item.createdby = isExist.createdby; item.updatedat = DateTime.Now; item.updatedby = currentUser.entryid; } item.AddOrUpdate(currentUser.entryid, null, false); return(Json(new { success = true, data = item })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { db.Close(); } }
protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { BillDetail billDetail = (BillDetail)e.Row.DataItem; TextBox tbAmount = (TextBox)e.Row.FindControl("tbAmount"); tbAmount.Attributes["oldValue"] = tbAmount.Text; TextBox tbQty = (TextBox)e.Row.FindControl("tbQty"); tbQty.Attributes["oldValue"] = tbQty.Text; TextBox tbDiscountRate = (TextBox)e.Row.FindControl("tbDiscountRate"); TextBox tbDiscount = (TextBox)e.Row.FindControl("tbDiscount"); if (billDetail.Bill.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE) { tbQty.ReadOnly = true; tbDiscountRate.ReadOnly = true; tbDiscount.ReadOnly = true; } } }
public void AddBillDetail(string billNo, IList <ActingBill> actingBillList, User user) { Bill oldBill = this.CheckAndLoadBill(billNo, true); #region 检查状态 if (oldBill.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE) { throw new BusinessErrorException("Bill.Error.StatusErrorWhenAddDetail", oldBill.Status, oldBill.BillNo); } #endregion if (actingBillList != null && actingBillList.Count > 0) { foreach (ActingBill actingBill in actingBillList) { ActingBill oldActingBill = this.actingBillMgr.LoadActingBill(actingBill.Id); oldActingBill.CurrentBillQty = actingBill.CurrentBillQty; oldActingBill.CurrentDiscount = actingBill.CurrentDiscount; BillDetail billDetail = this.billDetailMgr.TransferAtingBill2BillDetail(oldActingBill); billDetail.Bill = oldBill; oldBill.AddBillDetail(billDetail); if (billDetail.IsProvEst && !oldBill.HasProvEst) { oldBill.HasProvEst = true; } this.billDetailMgr.CreateBillDetail(billDetail); //扣减ActingBill数量和金额 this.actingBillMgr.ReverseUpdateActingBill(null, billDetail, user); } oldBill.LastModifyDate = DateTime.Now; oldBill.LastModifyUser = user; this.UpdateBill(oldBill); } }
public BillDetail IUD(BillDetail oBillDetail, int nUserID) { Connection.Open(); if (oBillDetail.BillDetailID == 0) { Command.CommandText = BillDetailDA.IUD(oBillDetail, EnumDBOperation.Insert, nUserID); } else { Command.CommandText = BillDetailDA.IUD(oBillDetail, EnumDBOperation.Update, nUserID); } SqlDataReader reader = Command.ExecuteReader(); BillDetail _oBillDetail = new BillDetail(); if (reader.HasRows) { _oBillDetail = MakeObject(reader); } reader.Close(); Connection.Close(); return(_oBillDetail); }
public BillDetail GetComboDetail(string id) { string sql = @" select ID, Name, Price from Combo where cb.ID = @id"; SqlCommand command = new SqlCommand { Connection = connection, CommandType = CommandType.Text, CommandText = sql, }; command.Parameters.Add("@id", SqlDbType.NVarChar).Value = id; SqlDataReader reader = command.ExecuteReader(); try { if (reader.Read()) { BillDetail billDetail = new BillDetail { Combo = new Combo { ID = reader.GetString(0), Name = reader.GetString(1) }, Price = reader.GetDecimal(2) }; return(billDetail); } else { return(null); } } finally { reader.Close(); } }
private void pictureBox1_Click_1(object sender, EventArgs e) { if (gvProductsToBills.Rows.Count == 0) { MessageBox.Show("Choose product, Please!", "Message"); return; } List <BillDetail> lstBillDetail = new List <BillDetail>(); for (int i = 0; i < gvProductsToBills.Rows.Count; i++) { BillDetail billDetail = new BillDetail() { ProductId = int.Parse(gvProductsToBills.Rows[i].Cells["colID"].Value.ToString()), Amounts = int.Parse(gvProductsToBills.Rows[i].Cells["colAmounts"].Value.ToString()), RealPrice = float.Parse(gvProductsToBills.Rows[i].Cells["colRealPrice"].Value.ToString()), Sum = float.Parse(gvProductsToBills.Rows[i].Cells["colTotal"].Value.ToString()), BillDetailDescription = string.Empty }; lstBillDetail.Add(billDetail); } Bill bills = new Bill() { CreatedDate = DateTime.Parse(DateTime.Now.ToShortDateString()), BillDescription = "", Total = double.Parse(lbTotal.Text), BillDetails = lstBillDetail }; BLLBills billsBLL = new BLLBills(); if (billsBLL.Inserted(bills)) { MessageBox.Show("Add Successful", "Message"); LoadGridBills(); } }
public BillDetail TransferAtingBill2BillDetail(ActingBill actingBill) { EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference( BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH); int amountDecimalLength = int.Parse(entityPreference.Value); BillDetail billDetail = new BillDetail(); billDetail.ActingBill = actingBill; billDetail.Currency = actingBill.Currency; billDetail.IsIncludeTax = actingBill.IsIncludeTax; billDetail.TaxCode = actingBill.TaxCode; billDetail.UnitPrice = actingBill.UnitPrice; billDetail.BilledQty = actingBill.CurrentBillQty; billDetail.Discount = actingBill.CurrentDiscount; billDetail.LocationFrom = actingBill.LocationFrom; billDetail.IpNo = actingBill.IpNo; billDetail.ReferenceItemCode = actingBill.ReferenceItemCode; billDetail.IsProvEst = actingBill.IsProvisionalEstimate; if (actingBill.CurrentBillQty != (actingBill.BillQty - actingBill.BilledQty)) { //本次开票数量大于剩余数量 if (Math.Abs(actingBill.CurrentBillQty) > Math.Abs(actingBill.BillQty - actingBill.BilledQty)) { throw new BusinessErrorException("ActingBill.Error.CurrentBillQtyGeRemainQty"); } //本次开票数量小于剩余数量 billDetail.OrderAmount = Math.Round((actingBill.BillAmount / actingBill.BillQty * actingBill.CurrentBillQty), amountDecimalLength, MidpointRounding.AwayFromZero); } else { //本次开票数量等于剩余数量 billDetail.OrderAmount = actingBill.BillAmount - actingBill.BilledAmount; } return(billDetail); }
private void btnEdit_Click(object sender, EventArgs e) { List <BillDetail> lstBillDetail = new List <BillDetail>(); for (int i = 0; i < gvProductsToBills.Rows.Count; i++) { BillDetail billDetail = new BillDetail() { ProductId = int.Parse(gvProductsToBills.Rows[i].Cells["colID"].Value.ToString()), Amounts = int.Parse(gvProductsToBills.Rows[i].Cells["colAmounts"].Value.ToString()), RealPrice = float.Parse(gvProductsToBills.Rows[i].Cells["colRealPrice"].Value.ToString()), Sum = float.Parse(gvProductsToBills.Rows[i].Cells["colTotal"].Value.ToString()), BillDetailDescription = string.Empty }; lstBillDetail.Add(billDetail); } Bill bills = new Bill() { BillId = int.Parse(gvBills.Rows[gvBills.CurrentCell.RowIndex].Cells["colBillsId"].Value.ToString()), CreatedDate = DateTime.Parse(gvBills.Rows[gvBills.CurrentCell.RowIndex].Cells["colBillsDate"].Value.ToString()), BillDescription = "", Total = SumTotal(), BillDetails = lstBillDetail }; BLLBills bllBills = new BLLBills(); bllBills.Updated(bills); MessageBox.Show("Update Successful", "Message"); LoadGridBills(); gvProductsToBills.Rows.Clear(); lbTotal.Text = string.Empty; pictureBox1.Enabled = true; pictureBox2.Enabled = true; btnEdit.Enabled = false; }
public String update(BillDetail p, String userId) { String re = ""; String sql = ""; int chk = 0; chkNull(p); sql = "Update " + bild.table + " Set " + " " + bild.bill_id + " = '" + p.bill_id + "'" + "," + bild.order_id + " = '" + p.order_id.Replace("'", "''") + "'" + "," + bild.remark + " = '" + p.remark.Replace("'", "''") + "'" + "," + bild.date_modi + " = now()" + "," + bild.user_modi + " = '" + userId + "' " + "," + bild.host_id + " = '" + p.host_id + "' " + "," + bild.branch_id + " = '" + p.branch_id + "' " + "," + bild.device_id + " = '" + p.device_id + "' " + "," + bild.row1 + " = '" + p.row1 + "' " + "," + bild.price + " = '" + p.price + "' " + "," + bild.foods_code + " = '" + p.foods_code + "' " + "," + bild.status_void + " = '" + p.status_void + "' " + "," + bild.qty + " = '" + p.qty + "' " + "," + bild.amount + " = '" + p.amount + "' " + //"," + bil.foods_cat_id + " = '" + p.foods_cat_id + "' " + "," + bild.lot_id + " = '" + p.lot_id + "' " + "Where " + bild.pkField + "='" + p.bill_detail_id + "'" ; try { re = conn.ExecuteNonQuery(conn.conn, sql); } catch (Exception ex) { sql = ex.Message + " " + ex.InnerException; } return(re); }
protected BillDetail GetObject(DataRow dr) { BillDetail objBillDetail = new BillDetail(); objBillDetail.Id = (dr["Id"] == DBNull.Value) ? 0 : (Int64)dr["Id"]; objBillDetail.BillMasterId = (dr["BillMasterId"] == DBNull.Value) ? 0 : (Int64)dr["BillMasterId"]; objBillDetail.MarketId = (dr["MarketId"] == DBNull.Value) ? 0 : (Int32)dr["MarketId"]; objBillDetail.ShopId = (dr["ShopId"] == DBNull.Value) ? 0 : (Int64)dr["ShopId"]; objBillDetail.MonthlyRent = (dr["MonthlyRent"] == DBNull.Value) ? 0 : (Decimal)dr["MonthlyRent"]; objBillDetail.ServiceCharge = (dr["ServiceCharge"] == DBNull.Value) ? 0 : (Decimal)dr["ServiceCharge"]; objBillDetail.MiscBills = (dr["MiscBills"] == DBNull.Value) ? 0 : (Decimal)dr["MiscBills"]; objBillDetail.ThisMonthTotal = (dr["ThisMonthTotal"] == DBNull.Value) ? 0 : (Decimal)dr["ThisMonthTotal"]; objBillDetail.PreviousDue = (dr["PreviousDue"] == DBNull.Value) ? 0 : (Decimal)dr["PreviousDue"]; objBillDetail.TotalAmount = (dr["TotalAmount"] == DBNull.Value) ? 0 : (Decimal)dr["TotalAmount"]; objBillDetail.LateFee = (dr["LateFee"] == DBNull.Value) ? 0 : (Decimal)dr["LateFee"]; objBillDetail.TotalAmountAfterLateFee = (dr["TotalAmountAfterLateFee"] == DBNull.Value) ? 0 : (Decimal)dr["TotalAmountAfterLateFee"]; objBillDetail.Payment = (dr["Payment"] == DBNull.Value) ? 0 : (Decimal)dr["Payment"]; objBillDetail.Due = (dr["Due"] == DBNull.Value) ? 0 : (Decimal)dr["Due"]; objBillDetail.IsClosed = (dr["IsClosed"] == DBNull.Value) ? false : (Boolean)dr["IsClosed"]; objBillDetail.ClosedBy = (dr["ClosedBy"] == DBNull.Value) ? 0 : (Int32)dr["ClosedBy"]; return objBillDetail; }
public void SearchRfidInfo(string rfid, Result result) { BillDetail[] billDetails = new BillDetail[] { }; try { var taryInfo = TrayInfoRepository.GetQueryable() .Where(t => t.TaryRfid == rfid) .Select(t => new BillDetail() { ProductCode = t.ProductCode, PieceQuantity = t.Quantity }).ToArray(); billDetails = billDetails.Concat(taryInfo).ToArray(); result.IsSuccess = true; result.BillDetails = billDetails; } catch (Exception e) { result.IsSuccess = false; result.Message = "调用服务器服务查询托盘信息失败!,详情:" + e.InnerException.Message + " 其他错误" + e.Message; } }
public void GetBillDetail(BillMaster[] billMasters, string productCode, string OperateType, string OperateAreas, string Operator, Result result) { BillDetail[] billDetails = new BillDetail[] { }; var ops = OperateAreas.Split(',').Select(a => Convert.ToInt32(a)).ToArray(); try { foreach (var billMaster in billMasters) { string billNo = billMaster.BillNo; switch (billMaster.BillType) { #region 读入库单细单 case "1"://入库单 var inBillDetails = InBillAllotRepository.GetQueryable() .WhereIn(m => m.Cell.Layer, ops) .Where(i => i.BillNo == billNo && (i.ProductCode == productCode || productCode == string.Empty) && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator))) .Select(i => new BillDetail() { BillNo = i.BillNo, BillType = "1" , DetailID = i.ID, StorageName = i.Cell.CellName, StorageRfid = i.Storage.Rfid, CellRfid = i.Cell.Rfid, TargetStorageName = "", TargetStorageRfid = "", ProductCode = i.ProductCode, ProductName = i.Product.ProductName, PieceQuantity =Math.Floor(i.AllotQuantity/i.Product.UnitList.Unit01.Count), BarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatePieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count), OperateBarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatorCode = string.Empty, Operator = i.Operator, Status = i.Status, }) .ToArray(); billDetails = billDetails.Concat(inBillDetails).ToArray(); break; #endregion #region 读出库单细单 case "2"://出库单 var outBillDetails = OutBillAllotRepository.GetQueryable() .WhereIn(m => m.Cell.Layer, ops) .Where(i => i.BillNo == billNo && (i.CanRealOperate == "1" || OperateType != "Real") && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator))) .Select(i => new BillDetail() { BillNo = i.BillNo, BillType = "2", DetailID = i.ID, StorageName = i.Cell.CellName, StorageRfid = i.Storage.Rfid, CellRfid =i.Cell.Rfid, TargetStorageName = "", TargetStorageRfid = "", ProductCode = i.ProductCode, ProductName = i.Product.ProductName, PieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count), BarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatePieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count), OperateBarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatorCode = string.Empty, Operator = i.Operator, Status = i.Status, }) .ToArray(); billDetails = billDetails.Concat(outBillDetails).ToArray(); var outBillMaster = OutBillMasterRepository.GetQueryable() .Where(i => i.BillNo == billNo) .FirstOrDefault(); if (outBillMaster != null && outBillMaster.MoveBillMasterBillNo != null) { billNo = outBillMaster.MoveBillMasterBillNo; //todo; var moveBillDetailss = MoveBillDetailRepository.GetQueryable() .WhereIn(m => m.InCell.Layer, ops) .Where(i => i.BillNo == billNo && (i.CanRealOperate == "1" || OperateType != "Real") && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator))) .ToArray() .Select(i => new BillDetail() { BillNo = i.BillNo, BillType = "3", DetailID = i.ID, StorageName = i.OutCell.CellName, StorageRfid = i.OutCell.Rfid, TargetStorageName = i.InCell.CellName, TargetStorageRfid = i.InCell.Rfid, ProductCode = i.ProductCode, ProductName = i.Product.ProductName, PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count), BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count), OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatorCode = string.Empty, Operator = i.Operator, Status = i.Status, }) .ToArray(); billDetails = billDetails.Concat(moveBillDetailss).ToArray(); } break; #endregion #region 读移库单细单 case "3"://移库单 var moveBillDetails = MoveBillDetailRepository.GetQueryable() .WhereIn(m => m.InCell.Layer, ops) .Where(i => i.BillNo == billNo && (i.CanRealOperate == "1" || OperateType != "Real") && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator))) .Select(i => new BillDetail() { BillNo = i.BillNo, BillType = "3", DetailID = i.ID, StorageName = i.OutCell.CellName, StorageRfid = i.OutStorage.Rfid, CellRfid = i.OutCell.Rfid, TargetStorageName = i.InCell.CellName, TargetStorageRfid = i.InCell.Rfid, ProductCode = i.ProductCode, ProductName = i.Product.ProductName, PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count), BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count), OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatorCode = string.Empty, Operator = i.Operator, Status = i.Status, PalletTag = i.PalletTag??0 }) .ToArray(); billDetails = billDetails.Concat(moveBillDetails).ToArray(); break; #endregion #region 读盘点单细单 case "4"://盘点单 var checkBillDetails = CheckBillDetailRepository.GetQueryable() .WhereIn(m => m.Cell.Layer, ops) .Where(i => i.BillNo == billNo && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator))) .Select(i => new BillDetail() { BillNo = i.BillNo, BillType = "4", DetailID = i.ID, StorageName = i.Cell.CellName, StorageRfid = i.Storage.Rfid, CellRfid = i.Cell.Rfid, TargetStorageName = "", TargetStorageRfid = "", ProductCode = i.ProductCode, ProductName = i.Product.ProductName, PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count), BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count), OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count), OperatorCode = string.Empty, Operator = i.Operator, Status = i.Status, }) .ToArray(); billDetails = billDetails.Concat(checkBillDetails).ToArray(); break; default: break; #endregion } } result.IsSuccess = true; result.BillDetails = billDetails.OrderByDescending(i => i.Status) .ThenByDescending(b => b.TargetStorageName).ToArray(); } catch (Exception e) { result.IsSuccess = false; result.Message = "调用服务器服务查询订单细表失败,详情:" + e.InnerException.Message + " 其他错误" + e.Message; } }
public void Execute(BillDetail[] billDetails, string useTag, Result result) { try { using (var scope = new TransactionScope()) { foreach (var billDetail in billDetails) { switch (billDetail.BillType) { #region 完成入库单 case "1": var inAllot = InBillAllotRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "1" && i.Operator == billDetail.Operator) .FirstOrDefault(); if (inAllot != null && (inAllot.InBillMaster.Status == "4" || inAllot.InBillMaster.Status == "5" )) { decimal quantity = billDetail.OperatePieceQuantity * inAllot.Product.UnitList.Unit01.Count + billDetail.OperateBarQuantity * inAllot.Product.UnitList.Unit02.Count; if (string.IsNullOrEmpty(inAllot.Storage.LockTag) && inAllot.AllotQuantity >= quantity && inAllot.Storage.InFrozenQuantity >= quantity) { inAllot.Status = "2"; inAllot.Storage.Rfid = billDetail.StorageRfid; inAllot.RealQuantity += quantity; inAllot.Storage.Quantity += quantity; if(inAllot.Storage.Cell.IsSingle=="1")//货位管理更改入库时间 inAllot.Storage.StorageTime = DateTime.Now; inAllot.Storage.InFrozenQuantity -= quantity; inAllot.InBillDetail.RealQuantity += quantity; inAllot.InBillMaster.Status = "5"; inAllot.FinishTime = DateTime.Now; if (inAllot.InBillMaster.InBillAllots.All(c => c.Status == "2")) { inAllot.InBillMaster.Status = "6"; } if (useTag == "1") CancelOperateToLabelServer(inAllot.BillNo, inAllot.ID.ToString(), inAllot.Cell.CellName); result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "需确认入库的数据别人在操作或完成的数量不对,完成出错!"; } } else { result.IsSuccess = false; result.Message = "需确认入库的数据查询为空或者主单状态不对,完成出错!"; } break; #endregion #region 完成出库单 case "2": var outAllot = OutBillAllotRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "1" && i.Operator == billDetail.Operator) .FirstOrDefault(); if (outAllot != null && (outAllot.OutBillMaster.Status == "4" || outAllot.OutBillMaster.Status == "5" )) { decimal quantity = billDetail.OperatePieceQuantity * outAllot.Product.UnitList.Unit01.Count + billDetail.OperateBarQuantity * outAllot.Product.UnitList.Unit02.Count; if (string.IsNullOrEmpty(outAllot.Storage.LockTag) && outAllot.AllotQuantity >= quantity && outAllot.Storage.OutFrozenQuantity >= quantity) { outAllot.Status = "2"; outAllot.RealQuantity += quantity; outAllot.Storage.Quantity -= quantity; if (outAllot.Storage.Quantity == 0) outAllot.Storage.Rfid = ""; outAllot.Storage.OutFrozenQuantity -= quantity; outAllot.OutBillDetail.RealQuantity += quantity; outAllot.OutBillMaster.Status = "5"; outAllot.FinishTime = DateTime.Now; if (outAllot.OutBillMaster.OutBillAllots.All(c => c.Status == "2")) { outAllot.OutBillMaster.Status = "6"; } if (useTag == "1") CancelOperateToLabelServer(outAllot.BillNo, outAllot.ID.ToString(), outAllot.Cell.CellName); result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "需确认出库的数据别人在操作或完成的数量不对,完成出错!"; } } else { result.IsSuccess = false; result.Message = "需确认出库的数据查询为空或者主单状态不对,完成出错!"; } break; #endregion #region 完成移库单 case "3": var moveDetail = MoveBillDetailRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "1" && i.Operator == billDetail.Operator) .FirstOrDefault(); if (moveDetail != null && (moveDetail.MoveBillMaster.Status =="2" || moveDetail.MoveBillMaster.Status =="3" )) { if (string.IsNullOrEmpty(moveDetail.InStorage.LockTag) && string.IsNullOrEmpty(moveDetail.OutStorage.LockTag) && moveDetail.InStorage.InFrozenQuantity >= moveDetail.RealQuantity && moveDetail.OutStorage.OutFrozenQuantity >= moveDetail.RealQuantity) { moveDetail.Status = "2"; moveDetail.InStorage.Quantity += moveDetail.RealQuantity; moveDetail.InStorage.InFrozenQuantity -= moveDetail.RealQuantity; moveDetail.InStorage.Rfid = billDetail.StorageRfid; moveDetail.OutStorage.Quantity -= moveDetail.RealQuantity; moveDetail.OutStorage.OutFrozenQuantity -= moveDetail.RealQuantity; moveDetail.OutStorage.Rfid = ""; //判断移入的时间是否小于移出的时间 if (DateTime.Compare(moveDetail.InStorage.StorageTime, moveDetail.OutStorage.StorageTime) == 1) moveDetail.InStorage.StorageTime = moveDetail.OutStorage.StorageTime; moveDetail.MoveBillMaster.Status = "3"; moveDetail.FinishTime = DateTime.Now; var sortwork = SortWorkDispatchRepository.GetQueryable().FirstOrDefault(s => s.MoveBillMaster.BillNo == moveDetail.MoveBillMaster.BillNo && s.DispatchStatus == "2"); //修改分拣调度作业状态 if (sortwork != null) { sortwork.DispatchStatus = "3"; } if (moveDetail.MoveBillMaster.MoveBillDetails.All(c => c.Status == "2")) { moveDetail.MoveBillMaster.Status = "4"; string errorInfo = ""; MoveBillDetailRepository.SaveChanges(); SettleSortWokDispatch(moveDetail.BillNo, ref errorInfo); } if (useTag == "1") CancelOperateToLabelServer(moveDetail.BillNo, moveDetail.ID.ToString(), moveDetail.OutCell.CellName); result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "需确认移库的数据别人在操作或者完成的数量不对,完成出错!"; } } else { result.IsSuccess = false; result.Message = "需确认移库的数据查询为空或者主单状态不对,完成出错!"; } break; #endregion #region 完成盘点单 case "4": var checkDetail = CheckBillDetailRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "1" && i.Operator == billDetail.Operator) .FirstOrDefault(); if (checkDetail != null && (checkDetail.CheckBillMaster.Status == "2" || checkDetail.CheckBillMaster.Status == "3")) { decimal quantity = billDetail.OperatePieceQuantity * checkDetail.Product.UnitList.Unit01.Count + billDetail.OperateBarQuantity * checkDetail.Product.UnitList.Unit02.Count; checkDetail.Status = "2"; checkDetail.RealQuantity = quantity; checkDetail.Storage.IsLock = "0"; checkDetail.CheckBillMaster.Status = "3"; checkDetail.FinishTime = DateTime.Now; if (checkDetail.CheckBillMaster.CheckBillDetails.All(c => c.Status == "2")) { checkDetail.CheckBillMaster.Status = "4"; } if (useTag == "1") CancelOperateToLabelServer(checkDetail.BillNo, checkDetail.ID.ToString(), checkDetail.Cell.CellCode); result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "需确认盘点的数据查询为空或者主单状态不对,完成出错!"; } break; default: break; #endregion } } InBillAllotRepository.SaveChanges(); //把库存为0,入库,出库冻结量为0,无锁的库存数据的卷烟编码清空 UpdateStorageInfo(); scope.Complete(); } } catch (Exception e) { result.IsSuccess = false; result.Message = "调用服务器服务执行作业任务失败,详情:" + e.InnerException.Message+" 其他错误:"+e.Message; } }
public void Cancel(BillDetail[] billDetails, string useTag, Result result) { try { using (var scope = new TransactionScope()) { foreach (var billDetail in billDetails) { switch (billDetail.BillType) { case "1": var inAllot = InBillAllotRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "1" && i.Operator == billDetail.Operator) .FirstOrDefault(); if (inAllot != null) { inAllot.Status = "0"; inAllot.Operator = string.Empty; inAllot.StartTime = null; if (useTag == "1") CancelOperateToLabelServer(inAllot.BillNo, inAllot.ID.ToString(), inAllot.Cell.CellName); result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "取消入库申请失败,原因:没有查询到这条数据!"; } break; case "2": var outAllot = OutBillAllotRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "1" && i.Operator == billDetail.Operator) .FirstOrDefault(); if (outAllot != null) { outAllot.Status = "0"; outAllot.Operator = string.Empty; outAllot.StartTime = null; if (useTag == "1") CancelOperateToLabelServer(outAllot.BillNo, outAllot.ID.ToString(), outAllot.Cell.CellName); result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "取消出库申请失败,原因:没有查询到这条数据!"; } break; case "3": var moveDetail = MoveBillDetailRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "1" && i.Operator == billDetail.Operator) .FirstOrDefault(); if (moveDetail != null) { moveDetail.Status = "0"; moveDetail.Operator = string.Empty; moveDetail.StartTime = null; if (useTag == "1") CancelOperateToLabelServer(moveDetail.BillNo, moveDetail.ID.ToString(), moveDetail.OutCell.CellName); result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "取消移库申请失败,原因:没有查询到这条数据!"; } break; case "4": var checkDetail = CheckBillDetailRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "1" && i.Operator == billDetail.Operator) .FirstOrDefault(); if (checkDetail != null) { checkDetail.Status = "0"; checkDetail.Operator = string.Empty; checkDetail.StartTime = null; if (useTag == "1") CancelOperateToLabelServer(checkDetail.BillNo, checkDetail.ID.ToString(), checkDetail.Cell.CellCode); result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "取消盘点申请失败,原因:没有查询到这条数据!"; } break; default: break; } } InBillAllotRepository.SaveChanges(); scope.Complete(); } } catch (Exception e) { result.IsSuccess = false; result.Message = "调用服务器服务取消作业任务失败,详情:" +e.InnerException.Message+" 其他错误:"+ e.Message; } }
public void Apply(BillDetail[] billDetails, string useTag, Result result) { try { using (var scope = new TransactionScope()) { foreach (var billDetail in billDetails) { switch (billDetail.BillType) { case "1": var inAllot = InBillAllotRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "0") .FirstOrDefault(); if (inAllot != null) { inAllot.Status = "1"; inAllot.Operator = billDetail.Operator; inAllot.StartTime = DateTime.Now; if (useTag == "1") { OperateToLabelServer(inAllot.BillNo, inAllot.ID.ToString(), inAllot.Cell.CellName, billDetail.BillType, inAllot.Product.ProductName, (int)billDetail.PieceQuantity, (int)billDetail.BarQuantity, ""); } result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "申请入库失败,原因:没有查询到这条数据!"; } break; case "2": var outAllot = OutBillAllotRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "0") .FirstOrDefault(); if (outAllot != null) { outAllot.Status = "1"; outAllot.Operator = billDetail.Operator; outAllot.StartTime = DateTime.Now; if (useTag == "1") { OperateToLabelServer(outAllot.BillNo, outAllot.ID.ToString(), outAllot.Cell.CellName, billDetail.BillType, outAllot.Product.ProductName, (int)billDetail.PieceQuantity, (int)billDetail.BarQuantity, ""); } result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "申请出库失败,原因:没有查询到这条数据!"; } break; case "3": var moveDetail = MoveBillDetailRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "0") .FirstOrDefault(); if (moveDetail != null) { moveDetail.Status = "1"; moveDetail.Operator = billDetail.Operator; moveDetail.StartTime = DateTime.Now; if (useTag == "1") { OperateToLabelServer(moveDetail.BillNo, moveDetail.ID.ToString(), moveDetail.OutCell.CellName, billDetail.BillType, moveDetail.Product.ProductName, (int)billDetail.PieceQuantity, (int)billDetail.BarQuantity, moveDetail.InCell.CellName); } result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "申请移库失败,原因:没有查询到这条数据!"; } break; case "4": var checkDetail = CheckBillDetailRepository.GetQueryable() .Where(i => i.BillNo == billDetail.BillNo && i.ID == billDetail.DetailID && i.Status == "0") .FirstOrDefault(); if (checkDetail != null) { checkDetail.Status = "1"; checkDetail.Operator = billDetail.Operator; checkDetail.StartTime = DateTime.Now; if (useTag == "1") { OperateToLabelServer(checkDetail.BillNo, checkDetail.ID.ToString(), checkDetail.Cell.CellName, billDetail.BillType, checkDetail.Product.ProductName, (int)billDetail.PieceQuantity, (int)billDetail.BarQuantity, ""); } result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "申请盘点失败,原因:没有查询到这条数据!"; } break; default: break; } } InBillAllotRepository.SaveChanges(); scope.Complete(); } } catch (Exception e) { result.IsSuccess = false; result.Message = "调用服务器服务申请作业任务失败,详情:" +e.InnerException.Message+" 其他错误 "+ e.Message; } }