コード例 #1
0
        /// <summary>
        /// 提交失败单据状况
        /// </summary>
        /// <returns>是否提交成功</returns>
        private bool ErrSubmit()
        {
            string  cCode = txtOrder.Text;
            DataSet ds;
            StockIn sk;

            sk = StockInBusiness.CreateSIOrderByDismantle("21", "", cCode, out ds);
            if (sk == null)
            {
                return(true);
            }
            if (sk.U8Details == null || sk.U8Details.Count < 1)
            {
                return(true);
            }
            if (sk.U8Details.Count != tempSIO.U8Details.Count)
            {
                return(true);
            }
            StockInDetail opera = tempSIO.OperateDetails[0];
            StockInDetail sd    = null;

            sd = sk.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == opera.cInvCode.ToUpper() && sdd.Batch.ToUpper() == opera.Batch.ToUpper()); });
            if (sd == null || sd.fShallInQuan != opera.fShallInQuan)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        public void AddStockIn(int[] selectedIds, int[] selectedValues, string user)
        {
            StockInDetail note = new StockInDetail();

            note.detailProductList = new List <Product>();

            var newList = new List <StockInDetail>();

            if (inList == null)
            {
                note.detailId = 1;
            }
            else
            {
                note.detailId = inList.Last().detailId + 1;
                newList       = new List <StockInDetail>(inList);
            }

            //Assign value for new note
            note.detailUser        = user;
            note.detailDateAdded   = DateTime.Now;
            note.detailProductList = new List <Product>();
            note.detailStockChange = new List <StockTracker>();
            List <Product> changedProducts = new List <Product>();

            (note.detailProductList, note.detailStockChange, changedProducts) = UpdateNoteProductList(selectedIds, selectedValues);
            if (note.detailProductList != null && note.detailStockChange != null && changedProducts != null)
            {
                newList.Add(note);
                //Update database
                UpdateProductList(changedProducts);
                LocalDataAccess.WriteDataStockIn(rootPath, stockInFile, newList);
            }
        }
コード例 #3
0
        private bool ReadBatch()
        {
            try
            {
                StockInDetail sdl = null;
                sdl = tempSIO.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode == txtLabel.Text.Trim() && sdd.Batch == lblBatch.Text); });
                if (sdl == null)
                {
                    return(false);
                }

                try
                {
                    if (sdl.Massdate > 0)
                    {
                        lblValityDate.Text = DateTime.Parse(sdl.Vdate).AddDays(-1).ToString("yyyy-MM-dd");
                        lblProDate.Text    = DateTime.Parse(sdl.Madedate).ToString("yyyy-MM-dd");
                    }
                    return(true);
                }
                catch
                {
                    lblProDate.Text    = "";
                    lblValityDate.Text = "";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
コード例 #4
0
        public bool AddIntoDB(StockInDetail stockInDetail)
        {
            try
            {
                OpenConnection();
                string queryString = "insert into CHITIETPHIEUNHAP(MaCTPN,MaPNH ,MaSP,SoLuong,DonGia) " +
                                     "values(@MaCTPN,@MaPNH, @MaSP, @SoLuong,@DonGia )";
                SqlCommand command = new SqlCommand(queryString, conn);
                command.Parameters.AddWithValue("@MaCTPN", stockInDetail.mACTPN.ToString());
                command.Parameters.AddWithValue("@MaPNH", stockInDetail.mAPNH.ToString());
                command.Parameters.AddWithValue("@MaSP", stockInDetail.mASP.ToString());
                command.Parameters.AddWithValue("@SoLuong", stockInDetail.sOLuong.ToString());
                command.Parameters.AddWithValue("@DonGia", stockInDetail.donGia.ToString());

                int rs = command.ExecuteNonQuery();
                if (rs != 1)
                {
                    throw new Exception();
                }
                else
                {
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            finally
            {
                CloseConnection();
            }
        }
コード例 #5
0
        /// <summary>
        /// 提交失败单据状况
        /// </summary>
        /// <returns>是否提交成功</returns>
        private bool ErrSubmit()
        {
            string  cCode = txtOrder.Text;
            DataSet ds;
            StockIn sk;

            sk = StockInBusiness.GetOMMOHead(cCode, out MODetails, out ds);
            if (sk.U8Details == null || sk.U8Details.Count < 1)
            {
                return(true);
            }
            if (sk.U8Details.Count != tempSIO.U8Details.Count)
            {
                return(true);
            }
            StockInDetail opera = tempSIO.OperateDetails[0];
            StockInDetail sd    = null;

            sd = sk.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == opera.cInvCode.ToUpper() && sdd.Batch.ToUpper() == opera.Batch.ToUpper()); });
            if (sd == null || sd.Nquantity != opera.Nquantity)
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
        public List <StockInDetail> GetStockInDetailById(string MaPNH)
        {
            List <StockInDetail> listStockInDetail = new List <StockInDetail>();

            try
            {
                OpenConnection();
                string         queryString = "select * from CHITIETPHIEUNHAP where MaPNH = " + MaPNH;
                SqlCommand     command     = new SqlCommand(queryString, conn);
                SqlDataAdapter adapter     = new SqlDataAdapter(command);

                DataTable dataTable = new DataTable();
                adapter.Fill(dataTable);
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    StockInDetail stockInDetail = new StockInDetail(int.Parse(dataTable.Rows[i].ItemArray[0].ToString()), int.Parse(dataTable.Rows[i].ItemArray[1].ToString()), int.Parse(dataTable.Rows[i].ItemArray[2].ToString()),
                                                                    int.Parse(dataTable.Rows[i].ItemArray[3].ToString()), int.Parse(dataTable.Rows[i].ItemArray[4].ToString()));

                    listStockInDetail.Add(stockInDetail);
                }
                return(listStockInDetail);
            }
            catch
            {
                return(new List <StockInDetail>());
            }
            finally
            {
                CloseConnection();
            }
        }
コード例 #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            StockInDetail stockInDetail = db.StockInDetails.Find(id);

            db.StockInDetails.Remove(stockInDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #8
0
ファイル: StockInDetailDAL.cs プロジェクト: ragsarma/ALLIUM
        public bool Delete(string documentNo, DbTransaction parentTransaction)
        {
            var stockdetailItem = new StockInDetail {
                DocumentNo = documentNo
            };

            return(Delete(stockdetailItem, parentTransaction));
        }
コード例 #9
0
        private bool RecordNum()
        {
            string _qty = txtCount.Text.Trim();

            try
            {
                if (txtOrder.Tag != null)
                {
                    decimal       qty   = Convert.ToDecimal(_qty) * scanCount;
                    decimal       inQty = 0;
                    StockInDetail sdl;
                    sdl = tempSIO.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == txtLabel.Text.Trim().ToUpper() && sdd.Batch.ToUpper() == lblBatch.Text.Trim().ToUpper() && sdd.Nquantity > 0); });

                    if (sdl == null)
                    {
                        MessageBox.Show("该批次货物已全部扫描!");
                        return(false);
                    }
                    inQty = sdl.fShallInQuan - sdl.Nquantity;

                    if (sdl.bInvBatch && string.IsNullOrEmpty(sdl.Batch))
                    {
                        MessageBox.Show("该货物有批次管理,请输入批次后重试!");
                        return(false);
                    }
                    else if (!sdl.bInvBatch && !string.IsNullOrEmpty(lblBatch.Text))
                    {
                        MessageBox.Show("该货物没有批次管理,请勿输入批次!");
                        return(false);
                    }

                    if (qty + inQty > sdl.fShallInQuan)
                    {
                        MessageBox.Show("扫描数量大于应入库数量!" + Environment.NewLine + "应不大于" + sdl.Nquantity.ToString("F4") + sdl.Inva_unit);
                        return(false);
                    }

                    StockInDetail tempSDL = sdl.getNewDetail();
                    if (!addData(qty, tempSDL))
                    {
                        return(false);
                    }
                    AddPosition(qty);
                    sdl.Nquantity -= qty;

                    Clear();
                    txtLabel.Focus();
                }
                return(true);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
                txtCount.Focus();
                return(false);
            }
        }
コード例 #10
0
ファイル: frmDone.cs プロジェクト: i-sync/dxt.app
        private void btnPosition_Click(object sender, EventArgs e)
        {
            if (doneType != 1 || stock.OperaPositions == null || stock.OperaPositions.Count < 1)
            {
                return;
            }
            StockInDetail          sdl     = stock.OperateDetails[dgDone.CurrentRowIndex];
            List <InvPositionInfo> tempPos = GetTempPosList(sdl);

            if (tempPos == null || tempPos.Count < 1)
            {
                return;
            }

            using (frmPosition frmPos = new frmPosition(tempPos))
            {
                decimal inQty = sdl.Quantity;
                int     count = tempPos.Count;
                frmPos.ShowDialog();
                if (count > tempPos.Count)
                {
                    StockInDetail sid;
                    if (stock.SaveVouch == "04")
                    {
                        sid = stock.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == sdl.cInvCode && sdd.cMoDetailsID == sdl.cMoDetailsID); });
                    }
                    else
                    {
                        sid = stock.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == sdl.cInvCode && sdd.Batch.ToUpper() == sdl.Batch); });
                    }
                    DelPosition(sdl.cInvCode, sdl.Batch);
                    if (tempPos == null || tempPos.Count < 1)
                    {
                        stock.OperateDetails.Remove(sdl);
                        sid.Nquantity += inQty;
                    }
                    else
                    {
                        decimal quan = 0;
                        foreach (InvPositionInfo pos in tempPos)
                        {
                            quan += pos.Quantity;
                        }
                        sdl.Quantity = quan;
                        if (tempPos.Count == 1)
                        {
                            sdl.Position = tempPos[0].PosCode;
                        }
                        stock.OperaPositions.AddRange(tempPos);
                        sid.Nquantity += (inQty - quan);
                    }
                }
            }

            BindData();
        }
コード例 #11
0
 public ActionResult Edit([Bind(Include = "Id,StockInId,ProductId,Qty")] StockInDetail stockInDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stockInDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", stockInDetail.ProductId);
     ViewBag.StockInId = new SelectList(db.StockIns, "Id", "Description", stockInDetail.StockInId);
     return(View(stockInDetail));
 }
コード例 #12
0
ファイル: frmDone.cs プロジェクト: i-sync/dxt.app
        /// <summary>
        /// 获取对应货位列表
        /// </summary>
        /// <param name="sdl">已扫信息</param>
        /// <returns>对应货位列表</returns>
        private List <InvPositionInfo> GetTempPosList(StockInDetail sdl)
        {
            List <InvPositionInfo> tempPos = new List <InvPositionInfo>();

            foreach (InvPositionInfo pos in stock.OperaPositions)
            {
                if (pos.InvCode == sdl.cInvCode && pos.Batch == sdl.Batch)
                {
                    tempPos.Add(pos);
                }
            }
            return(tempPos);
        }
コード例 #13
0
        // GET: StockInDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockInDetail stockInDetail = db.StockInDetails.Find(id);

            if (stockInDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(stockInDetail));
        }
コード例 #14
0
        private bool ReadPosition()
        {
            txtPosition.Text = txtPosition.Text.Trim().ToUpper();
            if (txtPosition.Text.IndexOf('-') != -1 || txtPosition.Text.IndexOf('@') != -1 || txtPosition.Text.Length > 12)
            {
                return(false);
            }
            StockInDetail position = null;

            position = tempSIO.OperateDetails.Find(delegate(StockInDetail sd) { return(sd.Position.ToUpper() == txtPosition.Text); });
            if (position != null)
            {
                return(true);
            }
            return(StockInBusiness.GetPTExist(tempSIO.Whcode, txtPosition.Text));
        }
コード例 #15
0
        // GET: StockInDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockInDetail stockInDetail = db.StockInDetails.Find(id);

            if (stockInDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", stockInDetail.ProductId);
            ViewBag.StockInId = new SelectList(db.StockIns, "Id", "Description", stockInDetail.StockInId);
            return(View(stockInDetail));
        }
コード例 #16
0
ファイル: frmPUIn.cs プロジェクト: i-sync/dxt.app
        /// <summary>
        /// 提交失败单据状况
        /// </summary>
        /// <returns>是否提交成功</returns>
        private bool ErrSubmit()
        {
            string  cCode = txtOrder.Text;
            DataSet ds;
            StockIn sk;

            if (rbtArrival.Checked)
            {
                sk = StockInBusiness.CreateSIOrderArrive(cCode, "", "", 0, out ds);
            }
            else
            {
                sk = StockInBusiness.CreateSIOrderByGSPVouch(null, cCode, out ds);
            }
            //行数是否相同
            if (sk == null)
            {
                return(true);
            }
            if (sk.U8Details == null || sk.U8Details.Count < 1)
            {
                return(true);
            }
            if (sk.U8Details.Count != tempSIO.U8Details.Count)
            {
                return(true);
            }
            //数量是否相同
            StockInDetail opera = tempSIO.OperateDetails[0];
            StockInDetail sd    = null;

            sd = sk.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == opera.cInvCode.ToUpper() && sdd.Batch.ToUpper() == opera.Batch.ToUpper()); });
            if (sd == null || sd.fShallInQuan != opera.fShallInQuan)
            {
                return(true);
            }

            return(false);
        }
コード例 #17
0
 public bool UpdateOnDB(StockInDetail stockInDetail)
 {
     try
     {
         OpenConnection();
         string queryString = "update CHITIETPHIEUNHAP set SoLuong=@SoLuong, DonGia=@DonGia " +
                              "where MaSP=@MaSP and MaPNH=@MaPNH";
         SqlCommand command = new SqlCommand(queryString, conn);
         command.Parameters.AddWithValue("@MaPNH", stockInDetail.mAPNH.ToString());
         command.Parameters.AddWithValue("@MaSP", stockInDetail.mASP.ToString());
         command.Parameters.AddWithValue("@SoLuong", stockInDetail.sOLuong.ToString());
         command.Parameters.AddWithValue("@DonGia", stockInDetail.donGia.ToString());
         command.ExecuteNonQuery();
         return(true);
     }
     catch
     {
         return(false);
     }
     finally
     {
         CloseConnection();
     }
 }
コード例 #18
0
        public static List <StockInDetail> ReadDataStockIn(string rootPath, string fileName)
        {
            string filePath = Path.Combine(rootPath, fileName);
            string text     = "";

            if (File.Exists(filePath))
            {
                text = File.ReadAllText(filePath);
                try
                {
                    var readList = JsonSerializer.Deserialize <List <SupportClass> >(text, options);
                    List <StockInDetail> trackList = new List <StockInDetail>();
                    foreach (var item in readList)
                    {
                        List <Product>      products = JsonSerializer.Deserialize <List <Product> >(item.detailProductList);
                        List <StockTracker> changes  = JsonSerializer.Deserialize <List <StockTracker> >(item.detailStockChange);
                        StockInDetail       itemNew  = new StockInDetail
                        {
                            detailId          = item.detailId,
                            detailDateAdded   = item.detailDateAdded,
                            detailUser        = item.detailUser,
                            detailProductList = products,
                            detailStockChange = changes
                        };
                        trackList.Add(itemNew);
                    }

                    return(trackList);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            return(null);
        }
コード例 #19
0
ファイル: frmOSStuffOut.cs プロジェクト: i-sync/dxt.app
        private bool ReadLabel()
        {
            foreach (StockInDetail sid in tempSIO.U8Details)
            {
                if (sid.cInvCode.ToUpper() == txtLabel.Text.Trim().ToUpper())
                {
                    if (sid.bInvBatch && batchList == null || sid.bInvBatch && batchList.Count < 1)
                    {
                        continue;
                    }
                    StockInDetail opare = null;
                    opare = tempSIO.OperateDetails.Find(delegate(StockInDetail odl) { return(odl.cInvCode == sid.cInvCode && odl.cMoDetailsID == sid.cMoDetailsID); });
                    if (opare != null)
                    {
                        if (opare.Quantity >= opare.fShallInQuan)
                        {
                            continue;
                        }
                    }
                    lblName.Text     = sid.Invname;    //品名
                    lblStandard.Text = sid.cInvStd;    //规格
                    //lblcInvCode.Text = sid.cInvCode;    //存货编码
                    lblAddrCode.Text = sid.Address;    //产地
                    decimal qty = 0;
                    foreach (StockInDetail sdd in tempSIO.OperateDetails)
                    {
                        if (sdd.cInvCode.ToUpper() == txtLabel.Text.Trim().ToUpper() && sdd.Quantity > 0 && sdd.Batch.ToUpper() == lblBatch.Text.Trim().ToUpper())
                        {
                            if (!string.IsNullOrEmpty(lblBatch.Text) && sdd.Batch.ToUpper() != lblBatch.Text.Trim().ToUpper())
                            {
                                continue;
                            }
                            qty += sdd.Quantity;
                        }
                    }
                    lblDoneNum.Text = qty.ToString("F4");

                    //非二维码扫描从来源单据读取产期
                    if (!is2Code && sid.bInvBatch && sid.Massdate > 0)
                    {
                        lblValityDate.Text = batchList[cbxBatch.SelectedIndex].Expirationdate;
                        lblProDate.Text    = batchList[cbxBatch.SelectedIndex].Mdate;
                        if (string.IsNullOrEmpty(lblValityDate.Text))
                        {
                            lblValityDate.Text = DateTime.Parse(lblProDate.Text).AddMonths(Convert.ToInt32(sid.Massdate)).AddDays(-1).ToString("yyyy-MM-dd");
                        }
                    }
                    //txtBatch.Text = sid.Batch;
                    //
                    cbxBatch.Visible = sid.bInvBatch;
                    cbxBatch.Enabled = sid.bInvBatch;
                    txtCount.Focus();
                    txtCount.SelectAll();
                    txtOrder.Tag = sid;
                    return(true);
                }
            }

            MessageBox.Show("没有相应的物料信息或已扫描完毕");
            Clear();
            return(false);
        }
コード例 #20
0
ファイル: StockInDetailBO.cs プロジェクト: ragsarma/ALLIUM
 public bool DeleteStockInDetail(StockInDetail item)
 {
     return(stockindetailDAL.Delete(item));
 }
コード例 #21
0
ファイル: StockInDetailBO.cs プロジェクト: ragsarma/ALLIUM
 public StockInDetail GetStockInDetail(StockInDetail item)
 {
     return((StockInDetail)stockindetailDAL.GetItem <StockInDetail>(item));
 }
コード例 #22
0
        private bool ScanLabel()
        {
            string errMsg     = "";
            string cInvCode   = "";
            string strBarCode = txtLabel.Text.Trim().ToUpper();

            txtLabel.Text = "";
            string[] barcode = new string[7] {
                "", "", "", "", "", "", ""
            };
            try
            {
                if (strBarCode.IndexOf('@') == -1)
                {   //一维码
                    is2Code    = false;
                    barcode[0] = strBarCode;
                    if (!Common.GetCInvCode(strBarCode, out cInvCode, out errMsg))
                    {
                        MessageBox.Show("没有找到对应的存货编码!");
                        return(false);
                    }
                    barcode[2]    = cInvCode;
                    txtLabel.Text = barcode[2];
                    StockInDetail sd;
                    sd = tempSIO.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode == cInvCode); });
                    if (sd != null && sd.bInvBatch)
                    {
                        cbxBatch.Visible = true;
                        cbxBatch.Enabled = true;
                        if (cbxBatch.DataSource != null && cbxBatch.Items.Count > 0)
                        {
                            return(true);
                        }
                        List <string> batchList = new List <string>();
                        foreach (StockInDetail sid in tempSIO.U8Details)
                        {
                            if (sid.cInvCode.ToUpper() == cInvCode.ToUpper())
                            {
                                StockInDetail opare = null;
                                opare = tempSIO.OperateDetails.Find(delegate(StockInDetail odl) { return(odl.cInvCode == sid.cInvCode && odl.Batch == sid.Batch); });
                                if (opare != null && opare.Quantity >= sid.fShallInQuan)
                                {
                                    continue;
                                }
                                string temp = null;
                                temp = batchList.Find(delegate(string batch) { return(batch.ToUpper() == sid.Batch.ToUpper()); });
                                if (string.IsNullOrEmpty(temp))
                                {
                                    batchList.Add(sid.Batch.ToUpper());
                                }
                            }
                        }
                        cbxBatch.DataSource = batchList;
                        if (cbxBatch.Items.Count > 0)
                        {
                            cbxBatch.SelectedIndex = 0;
                        }
                        //else
                        //    return false;
                        if (cbxBatch.DataSource != null && cbxBatch.Items.Count > 0)
                        {
                            lblBatch.Text = cbxBatch.SelectedValue.ToString();
                        }
                    }
                }
                else
                {   //二维码
                    is2Code          = true;
                    barcode          = strBarCode.Split('@');
                    cbxBatch.Visible = false;
                    cbxBatch.Enabled = false;
                    lblBatch.Enabled = true;
                    lblBatch.Visible = true;
                    if (!Common.GetCInvCode(barcode[0], out cInvCode, out errMsg))
                    {
                        MessageBox.Show("没有找到对应的存货编码!");
                        return(false);
                    }
                    barcode[2]    = cInvCode;
                    txtLabel.Text = barcode[2];
                    lblBatch.Text = string.IsNullOrEmpty(barcode[3]) ? "" : barcode[3];
                    try
                    {
                        lblProDate.Text    = DateTime.Parse(barcode[4]).ToString("yyyy-MM-dd");
                        lblValityDate.Text = DateTime.Parse(barcode[5]).ToString("yyyy-MM-dd");
                    }
                    catch
                    {
                        lblProDate.Text    = Common.err_Time.ToString("yyy-MM-dd");
                        lblValityDate.Text = Common.err_Time.ToString("yyy-MM-dd");
                    }
                }
                if (barcode.Length < 7 || string.IsNullOrEmpty(barcode[6]))
                {
                    scanCount = 1;
                }
                else
                {
                    try { scanCount = decimal.Parse(barcode[6]); }
                    catch { scanCount = 1; }
                }
                return(true);
            }
            catch
            {
                Clear();
                MessageBox.Show("对不起,条码格式错误!");
                return(false);
            }
            finally { SetFocus(); }
        }
コード例 #23
0
ファイル: StockInDetailBO.cs プロジェクト: ragsarma/ALLIUM
 public bool SaveStockInDetail(StockInDetail newItem)
 {
     return(stockindetailDAL.Save(newItem));
 }
コード例 #24
0
        private bool RecordNum()
        {
            string _qty = txtCount.Text.Trim();

            try
            {
                if (txtOrder.Tag != null)
                {
                    //ln.Write("qty:", _qty);
                    if (_qty == "")
                    {
                        MessageBox.Show("未输入数量!");
                        return(false);
                    }
                    if (!isNumeric(_qty))
                    {
                        MessageBox.Show("请输入数字!");
                        return(false);
                    }
                    decimal       qty   = Convert.ToDecimal(_qty) * scanCount;
                    decimal       inQty = 0;
                    StockInDetail sdl;
                    sdl = tempSIO.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == txtLabel.Text.Trim().ToUpper() && sdd.Batch.ToUpper() == lblBatch.Text.Trim().ToUpper() && sdd.Nquantity > 0); });

                    if (sdl == null)
                    {
                        MessageBox.Show("该批次货物已全部扫描!");
                        return(false);
                    }
                    inQty = sdl.fShallInQuan - sdl.Nquantity;

                    if (sdl.bInvBatch && string.IsNullOrEmpty(lblBatch.Text))
                    {
                        MessageBox.Show("该货物有批次管理,请输入批次后重试!");
                        return(false);
                    }

                    if (qty + inQty > sdl.Nquantity)
                    {
                        MessageBox.Show("扫描数量大于应出库数量!");
                        return(false);
                    }

                    if (qty + inQty > StockInBusiness.GetPTQuan(txtLabel.Text, lblBatch.Text, tempSIO.Whcode, txtPosition.Text))
                    {
                        MessageBox.Show("扫描数量大于货位现有数量!");
                        return(false);
                    }

                    StockInDetail tempSDL = sdl.getNewDetail();
                    if (!addData(qty, tempSDL))
                    {
                        return(false);
                    }
                    AddPosition(qty);

                    Clear();
                    txtLabel.Focus();
                }
                return(true);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
                txtCount.Focus();
                return(false);
            }
        }
コード例 #25
0
        private bool addData(decimal _qty, StockInDetail sd)
        {
            try
            {
                string strPostion = string.IsNullOrEmpty(txtPosition.Text) ? "" : txtPosition.Text.Trim().ToUpper();
                sd.Batch = lblBatch.Text.Trim().ToUpper();

                if (tempSIO.OperateDetails.Count > 0)
                {
                    foreach (StockInDetail siodl in tempSIO.OperateDetails)
                    {
                        if (siodl.cInvCode == sd.cInvCode && siodl.Batch == sd.Batch && siodl.Nquantity > 0)//看还要加什么条件?
                        {
                            if (siodl.fShallInQuan >= _qty + siodl.Quantity)
                            {
                                siodl.Quantity = siodl.Quantity + Convert.ToDecimal(_qty);

                                siodl.Price       = siodl.Quantity * siodl.Unitcost;
                                siodl.Taxprice    = siodl.Price * siodl.Taxrate * Convert.ToDecimal(0.01);
                                siodl.Sum         = siodl.Price + siodl.Taxprice;
                                siodl.Orimoney    = siodl.Quantity * siodl.Oricost;
                                siodl.Oritaxprice = siodl.Orimoney * siodl.Taxrate * Convert.ToDecimal(0.01);
                                siodl.Orisum      = siodl.Orimoney + siodl.Oritaxprice;
                                if (!string.IsNullOrEmpty(strPostion) && siodl.Position != strPostion)
                                {
                                    siodl.Position = "";
                                }

                                return(true);
                            }
                            else
                            {
                                MessageBox.Show("已扫描数量大于最大扫描数量" + Environment.NewLine + "应小于" + sd.Nquantity.ToString("F4") + sd.Invm_unit + ",已扫描" + siodl.Quantity.ToString("F4") + sd.Invm_unit);
                                Clear();
                                return(false);
                            }
                        }
                    }
                }
                sd.cWhCode     = tempSIO.Whcode;
                sd.cWhName     = tempSIO.Whname;
                sd.Bvencode    = tempSIO.Vencode;
                sd.Venname     = tempSIO.Venname;
                sd.Quantity    = _qty;
                sd.Price       = sd.Quantity * sd.Unitcost;
                sd.Taxprice    = sd.Price * sd.Taxrate * Convert.ToDecimal(0.01);
                sd.Sum         = sd.Price + sd.Taxprice;
                sd.Orimoney    = sd.Quantity * sd.Oricost;
                sd.Oritaxprice = sd.Orimoney * sd.Taxrate * Convert.ToDecimal(0.01);
                sd.Orisum      = sd.Orimoney + sd.Oritaxprice;
                if (sd.Massdate > 0)
                {
                    sd.Madedate        = lblProDate.Text;
                    sd.cExpirationDate = lblValityDate.Text;
                    if (!string.IsNullOrEmpty(sd.cExpirationDate.Trim()))
                    {
                        sd.Vdate = DateTime.Parse(sd.cExpirationDate).AddDays(1).ToString("yyyy-MM-dd");
                    }
                    sd.Massunit = "2";
                }
                if (!string.IsNullOrEmpty(strPostion) && tempSIO.WhPos)
                {
                    sd.Position = strPostion;
                    sd.IsPos    = true;
                }

                tempSIO.OperateDetails.Add(sd);

                btnSubmit.Enabled = true;
                return(true);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
                txtCount.Focus();
                return(false);
            }
        }
コード例 #26
0
        private bool addData(decimal _qty, StockInDetail sd)
        {
            try
            {
                string strPostion = string.IsNullOrEmpty(txtPosition.Text) ? "" : txtPosition.Text.Trim().ToUpper();
                sd.Batch    = lblBatch.Text.Trim().ToUpper();
                sd.Unitcost = decimal.Parse(txtUnitCost.Text);
                sd.Oricost  = decimal.Parse(txtUnitCost.Text);
                if (tempSIO.OperateDetails.Count > 0)
                {
                    foreach (StockInDetail siodl in tempSIO.OperateDetails)
                    {
                        if (siodl.cInvCode.ToUpper() == sd.cInvCode.ToUpper() && siodl.VouchRowNo == sd.VouchRowNo && siodl.Batch == sd.Batch && siodl.Nquantity > 0)//看还要加什么条件?
                        {
                            if (siodl.Nquantity >= _qty + siodl.Quantity)
                            {
                                siodl.Quantity = siodl.Quantity + Convert.ToDecimal(_qty);

                                siodl.Price       = siodl.Quantity * siodl.Unitcost;
                                siodl.Taxprice    = siodl.Price * siodl.Taxrate * Convert.ToDecimal(0.01);
                                siodl.Sum         = siodl.Price + siodl.Taxprice;
                                siodl.Orimoney    = siodl.Quantity * siodl.Oricost;
                                siodl.Oritaxprice = siodl.Orimoney * siodl.Taxrate * Convert.ToDecimal(0.01);
                                siodl.Orisum      = siodl.Orimoney + siodl.Oritaxprice;
                                if (!string.IsNullOrEmpty(strPostion) && siodl.Position != strPostion)
                                {
                                    siodl.Position = "";
                                }

                                return(true);
                            }
                            else
                            {
                                MessageBox.Show("已扫描数量大于最大扫描数量");
                                Clear();
                                return(false);
                            }
                        }
                    }
                }
                sd.cWhCode     = tempSIO.Whcode;
                sd.cWhName     = tempSIO.Whname;
                sd.Bvencode    = tempSIO.Vencode;
                sd.Venname     = tempSIO.Venname;
                sd.Quantity    = _qty;
                sd.Price       = sd.Quantity * sd.Unitcost;
                sd.Taxprice    = sd.Price * sd.Taxrate * Convert.ToDecimal(0.01);
                sd.Sum         = sd.Price + sd.Taxprice;
                sd.Orimoney    = sd.Quantity * sd.Oricost;
                sd.Oritaxprice = sd.Orimoney * sd.Taxrate * Convert.ToDecimal(0.01);
                sd.Orisum      = sd.Orimoney + sd.Oritaxprice;
                if (sd.Massdate > 0)
                {
                    sd.Madedate        = lblProDate.Text;
                    sd.cExpirationDate = lblValityDate.Text;
                    if (!string.IsNullOrEmpty(sd.cExpirationDate.Trim()))
                    {
                        sd.Vdate = DateTime.Parse(sd.cExpirationDate).AddDays(1).ToString("yyyy-MM-dd");
                    }
                    sd.Massunit = "2";
                }
                if (!string.IsNullOrEmpty(strPostion) && tempSIO.WhPos)
                {
                    sd.Position = strPostion;
                    sd.IsPos    = true;
                }

                Om_MoHeadInfo ommo;
                ommo = MODetails.Find(delegate(Om_MoHeadInfo omhi) { return(omhi.MoDetailsID == cbxMoDetails.SelectedValue.ToString()); });
                if (ommo != null)
                {
                    sd.InvCCode = ommo.InvCode;
                }

                tempSIO.OperateDetails.Add(sd);

                btnSubmit.Enabled = true;
                return(true);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
                txtCount.Focus();
                return(false);
            }
        }
コード例 #27
0
ファイル: frmOSStuffOut.cs プロジェクト: i-sync/dxt.app
        private bool RecordNum()
        {
            string _qty = txtCount.Text.Trim();

            try
            {
                if (txtOrder.Tag != null)
                {
                    decimal       qty   = Convert.ToDecimal(_qty) * scanCount;
                    decimal       inQty = 0;
                    StockInDetail sdl;
                    sdl = tempSIO.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == txtLabel.Text.Trim().ToUpper() && sdd.Nquantity > 0); });

                    if (sdl == null)
                    {
                        MessageBox.Show("该批次货物已全部扫描!");
                        return(false);
                    }

                    //if (sdl.Nquantity <= 0)
                    //{
                    //    DialogResult res = MessageBox.Show("该货物已全部扫描,仍需要扫描吗?", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    //    if (res == DialogResult.No)
                    //    {
                    //        return false;
                    //    }
                    //}
                    inQty = sdl.fShallInQuan - sdl.Nquantity;

                    if (sdl.bInvBatch && string.IsNullOrEmpty(lblBatch.Text))
                    {
                        MessageBox.Show("该货物有批次管理,请输入批次后重试!");
                        return(false);
                    }
                    else if (!sdl.bInvBatch && !string.IsNullOrEmpty(lblBatch.Text))
                    {
                        MessageBox.Show("该货物没有批次管理,请勿输入批次!");
                        return(false);
                    }

                    if (qty + inQty > sdl.fShallInQuan)
                    {
                        MessageBox.Show("扫描数量大于最大出库数量!" + Environment.NewLine + "应不大于" + sdl.Nquantity.ToString("F4") + sdl.Inva_unit);
                        Clear();
                        return(false);
                    }

                    if (!string.IsNullOrEmpty(txtPosition.Text))
                    {
                        if (qty + inQty > StockInBusiness.GetPTQuan(txtLabel.Text, "", tempSIO.Whcode, txtPosition.Text))
                        {
                            MessageBox.Show("扫描数量大于货位现有数量!");
                            Clear();
                            return(false);
                        }
                    }

                    if (qty + inQty > StockInBusiness.GetWHQuan(txtLabel.Text, "", tempSIO.Whcode))
                    {
                        MessageBox.Show("扫描数量大于库存现有数量!");
                        Clear();
                        return(false);
                    }

                    if (batchList != null && batchList.Count > 0)
                    {
                        if (inQty > 0)
                        {
                            StockInDetail sid;
                            sid = tempSIO.OperateDetails.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode.ToUpper() == txtLabel.Text.Trim().ToUpper() && sdd.Batch == lblBatch.Text && sdd.Quantity > 0); });
                            if (sid != null)
                            {
                                inQty = sid.Quantity;
                            }
                            else
                            {
                                inQty = 0;
                            }
                        }
                        if (qty + inQty > batchList[cbxBatch.SelectedIndex].Quantity)
                        {
                            MessageBox.Show("扫描数量大于该批次现有数量!");
                            Clear();
                            return(false);
                        }
                    }

                    StockInDetail tempSDL = sdl.getNewDetail();
                    if (!addData(qty, tempSDL))
                    {
                        return(false);
                    }
                    AddPosition(qty);
                    sdl.Nquantity -= qty;

                    Clear();
                    txtLabel.Focus();
                }
                return(true);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
                txtCount.Focus();
                return(false);
            }
        }
コード例 #28
0
ファイル: frmOSStuffOut.cs プロジェクト: i-sync/dxt.app
        private bool addData(decimal _qty, StockInDetail sd)
        {
            try
            {
                string strPostion = string.IsNullOrEmpty(txtPosition.Text) ? "" : txtPosition.Text.Trim().ToUpper();
                sd.Batch = lblBatch.Text.Trim().ToUpper();
                StockInDetail siodl;
                siodl = tempSIO.OperateDetails.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode == sd.cInvCode && sdd.Batch == sd.Batch && sdd.cMoDetailsID == sd.cMoDetailsID && sdd.Nquantity > 0); });

                if (tempSIO.OperateDetails.Count > 0 && siodl != null)
                {
                    decimal quan = 0;
                    foreach (StockInDetail si in tempSIO.OperateDetails)
                    {
                        if (si.cInvCode == sd.cInvCode && si.cMoDetailsID == sd.cMoDetailsID)
                        {
                            quan += si.Quantity;
                        }
                    }
                    if (siodl.fShallInQuan >= _qty + quan)
                    {
                        siodl.Quantity = siodl.Quantity + Convert.ToDecimal(_qty);

                        siodl.Price       = siodl.Quantity * siodl.Unitcost;
                        siodl.Taxprice    = siodl.Price * siodl.Taxrate * Convert.ToDecimal(0.01);
                        siodl.Sum         = siodl.Price + siodl.Taxprice;
                        siodl.Orimoney    = siodl.Quantity * siodl.Oricost;
                        siodl.Oritaxprice = siodl.Orimoney * siodl.Taxrate * Convert.ToDecimal(0.01);
                        siodl.Orisum      = siodl.Orimoney + siodl.Oritaxprice;
                        if (!string.IsNullOrEmpty(strPostion) && siodl.Position != strPostion)
                        {
                            siodl.Position = "";
                        }

                        return(true);
                    }
                    else
                    {
                        MessageBox.Show("已扫描数量大于最大扫描数量");
                        Clear();
                        return(false);
                    }
                }
                sd.InvCode = tempSIO.PspCode;
                sd.cWhCode = tempSIO.Whcode;
                sd.cWhName = tempSIO.Whname;
                //sd.Bvencode = tempSIO.Vencode;
                sd.Quantity    = _qty;
                sd.Price       = sd.Quantity * sd.Unitcost;
                sd.Taxprice    = sd.Price * sd.Taxrate * Convert.ToDecimal(0.01);
                sd.Sum         = sd.Price + sd.Taxprice;
                sd.Orimoney    = sd.Quantity * sd.Oricost;
                sd.Oritaxprice = sd.Orimoney * sd.Taxrate * Convert.ToDecimal(0.01);
                sd.Orisum      = sd.Orimoney + sd.Oritaxprice;
                sd.Batch       = lblBatch.Text.Trim();
                if (sd.Massdate > 0)
                {
                    sd.Madedate        = lblProDate.Text;
                    sd.cExpirationDate = lblValityDate.Text;
                    if (!string.IsNullOrEmpty(sd.cExpirationDate.Trim()))
                    {
                        sd.Vdate = DateTime.Parse(sd.cExpirationDate).AddDays(1).ToString("yyyy-MM-dd");
                    }
                    sd.Massunit = "2";
                }
                if (!string.IsNullOrEmpty(strPostion) && tempSIO.WhPos)
                {
                    sd.Position = strPostion;
                    sd.IsPos    = true;
                }

                tempSIO.OperateDetails.Add(sd);

                btnSubmit.Enabled = true;
                return(true);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
                txtCount.Focus();
                return(false);
            }
        }
コード例 #29
0
ファイル: POController.cs プロジェクト: anhkhoa1611/khoaluan
        public ActionResult Approve(string data)
        {
            if (accessDetail.sua)
            {
                using (var dbConn = Helpers.OrmliteConnection.openConn())
                {
                    string[] separators = { "@@" };
                    var      listItem   = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var itemid in listItem)
                    {
                        var poheader  = dbConn.FirstOrDefault <POHeader>(s => s.id == int.Parse(itemid));
                        var podetails = dbConn.Select <PODetail>(s => s.ma_phieu_header == poheader.ma_phieu);

                        //var lstStockIn = podetail.GroupBy(
                        //                p => p.ma_chi_nhanh,
                        //                (key, g) => new { ma_chi_nhanh = key, Details = g.ToList() });
                        //foreach (var stockin in lstStockIn)
                        //{
                        StockInHeader stockinheader = new StockInHeader();
                        string        ma_phieu      = "";
                        var           loai          = "SI";
                        //var ma_don_vi = currentUser.ma_don_vi;
                        var yyMMdd    = DateTime.Now.ToString("yyMMdd");
                        var existLast = dbConn.SingleOrDefault <StockInHeader>("SELECT TOP 1 * FROM StockInHeader ORDER BY id DESC");
                        var nextNo    = 0;
                        var yearNow   = int.Parse(DateTime.Now.Year.ToString().Substring(2, 2));
                        if (existLast != null)
                        {
                            nextNo = int.Parse(existLast.ma_phieu.Substring(8, existLast.ma_phieu.Length - 8)) + 1;
                            var yearOld = int.Parse(existLast.ma_phieu.Substring(2, 2));
                            if (yearOld == yearNow)
                            {
                                ma_phieu = loai + yyMMdd + String.Format("{0:00000}", nextNo);
                            }
                            else
                            {
                                ma_phieu = loai + yyMMdd + "00001";
                            }
                        }
                        else
                        {
                            ma_phieu = loai + yyMMdd + "00001";
                        }

                        stockinheader.ma_phieu = ma_phieu;

                        //stockinheader.ten_phieu_nhap_kho = stockinheader.ma_phieu_nhap_kho;
                        //stockinheader.ma_don_vi = stockin.ma_chi_nhanh;
                        //stockinheader.ma_phieu_po = poheader.ma_phieu;
                        stockinheader.ma_nha_cung_cap = poheader.ma_nha_cung_cap;
                        stockinheader.ghi_chu         = poheader.ghi_chu;
                        stockinheader.ngay_tao        = DateTime.Now;
                        stockinheader.nguoi_tao       = currentUser.ma_nguoi_dung;
                        stockinheader.ngay_cap_nhat   = DateTime.Parse("1900-01-01");
                        stockinheader.nguoi_cap_nhat  = "";
                        stockinheader.trang_thai      = "MOI";
                        dbConn.Insert(stockinheader);

                        foreach (var item in podetails)
                        {
                            StockInDetail newdata = new StockInDetail();
                            newdata.ma_phieu_header    = stockinheader.ma_phieu;
                            newdata.ma_san_pham        = item.ma_san_pham;
                            newdata.so_luong           = item.so_luong;
                            newdata.so_luong_da_nhap   = 0;
                            newdata.so_luong_con_lai   = item.so_luong;
                            newdata.id_po_detail       = item.id;
                            newdata.thong_so_ky_thuat  = item.thong_so_ky_thuat;
                            newdata.muc_dich_su_dung   = "";
                            newdata.nguoi_tao          = currentUser.ma_nguoi_dung;
                            newdata.ma_to_trinh        = item.ma_to_trinh;
                            newdata.id_StatementDetail = item.id_StatementDetail;
                            newdata.don_gia_vat        = item.don_gia_vat;
                            newdata.don_gia            = item.don_gia;
                            newdata.thue_vat           = item.thue_vat;
                            newdata.don_vi_tinh        = item.don_vi_tinh;
                            newdata.chi_phi            = item.chi_phi;
                            newdata.ma_don_vi          = item.ma_don_vi;
                            newdata.ma_chi_nhanh       = item.ma_chi_nhanh;
                            newdata.thong_tin_noi_bo   = item.thong_tin_noi_bo;
                            newdata.ngay_tao           = DateTime.Now;
                            newdata.ngay_cap_nhat      = DateTime.Parse("1900-01-01");
                            newdata.nguoi_cap_nhat     = "";
                            newdata.trang_thai         = "";
                            dbConn.Insert <StockInDetail>(newdata);
                        }
                        dbConn.Update <POHeader>(set: "trang_thai = {0}, ngay_duyet = {1}".Params(AllConstant.TRANGTHAI_DA_DUYET, DateTime.Now), where : "id = {0}".Params(int.Parse(itemid)));
                    }

                    //}
                    return(Json(new { success = true }));
                }
            }
            else
            {
                return(Json(new { success = false, error = "Bạn không có quyền duyệt đơn đặt hàng" }));
            }
        }
コード例 #30
0
        public ReturnValue SaveStockInDetail(string no, List <StockDetailModel> list, int supplier, string remark, string deport)
        {
            using (var c = new InvoicingContext())
            {
                try
                {
                    var model = c.StockIns.FirstOrDefault(p => p.stockInNo == no && p.status == 0);
                    if (model == null)
                    {
                        return new ReturnValue {
                                   status = false, message = "不存在入库单"
                        }
                    }
                    ;
                    if (list == null || list.Count < 1)
                    {
                        return new ReturnValue {
                                   status = false, message = "不存在入库单"
                        }
                    }
                    ;
                    foreach (var item in list)
                    {
                        if (item.type == "")
                        {
                            continue;
                        }

                        if (item.type == "delete")
                        {
                            var d = c.StockInDetails.FirstOrDefault(p => p.detailSn == item.detailSn);
                            if (d != null)
                            {
                                c.StockInDetails.Remove(d);
                            }
                        }
                        else if (item.type == "edit")
                        {
                            var d = c.StockInDetails.FirstOrDefault(p => p.detailSn == item.detailSn);
                            if (d != null)
                            {
                                d.materialNo     = item.materialNo;
                                d.inAmount       = item.amount;
                                d.depotId        = item.depotId;
                                d.remark         = item.remark;
                                c.Entry(d).State = EntityState.Modified;
                            }
                        }
                        else if (item.type == "add")
                        {
                            StockInDetail d = new StockInDetail();
                            d.materialNo = item.materialNo;
                            d.inAmount   = item.amount;
                            d.stockinNo  = no;
                            if (item.purchaseDetailSn != 0)
                            {
                                d.purchaseDetailSn = item.purchaseDetailSn;
                                d.purchaseNo       = item.purchaseNo;
                            }
                            d.remark  = item.remark;
                            d.depotId = item.depotId;
                            c.StockInDetails.Add(d);
                        }
                    }
                    #region 申请单
                    if (model.remark != remark || model.deportStaff != deport)
                    {
                        model.remark = remark;

                        model.deportStaff    = deport;
                        c.Entry(model).State = EntityState.Modified;
                    }
                    #endregion
                    c.SaveChanges(); return(new ReturnValue {
                        status = true, message = ""
                    });
                }
                catch (Exception ex)
                {
                    return(new ReturnValue {
                        status = false, message = "保存失败:" + ex.Message
                    });
                }
            }
        }