protected override bool getRecords(out List <ProductCirculationRecord> records)
        {
            records = new List <ProductCirculationRecord>();

            int number = this.dataGridView1.RowCount;

            double num, price, totalPrice, quantityPerPiece;
            int    pieces;
            bool   isQuantityNull = false, isPiecesNull = false;
            string unit, comment;
            bool   isInputCorrect = true;

            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {
                object productID = null;
                int    ID        = 0;
                if (ValidateUtility.getLookupValue(row.Cells["product"], out productID) == false ||
                    ValidateUtility.getInt(row.Cells["ID"], false, true, out ID) == false ||
                    ValidateUtility.getDouble(row.Cells["quantityPerPiece"], false, true, out quantityPerPiece, out isQuantityNull) == false ||
                    ValidateUtility.getInt(row.Cells["pieces"], false, true, out pieces, out isPiecesNull) == false ||
                    ValidateUtility.getDouble(row.Cells["num"], true, true, out num) == false ||
                    ValidateUtility.getString(row.Cells["unit"], false, out unit) == false ||
                    ValidateUtility.getDouble(row.Cells["price"], out price) == false ||
                    ValidateUtility.getDouble(row.Cells["totalPrice"], out totalPrice) == false ||
                    ValidateUtility.getString(row.Cells["comment"], false, out comment) == false)
                {
                    return(false);
                }
                ProductStainlessCirculationRecord record = new ProductStainlessCirculationRecord();

                LookupArg arg = ((row.Cells["product"] as DataGridViewLookupCell).EditedValue as LookupArg);
                record.ProductID   = (int)arg.Value;
                record.ProductName = arg.Text;

                record.ID = ID;

                string serial;
                ValidateUtility.getString(row.Cells["serial"], false, out serial);
                record.Serial = serial;

                record.QuantityPerPiece = quantityPerPiece;
                record.QuantityNull     = isQuantityNull;

                record.Pieces     = pieces;
                record.PiecesNull = isPiecesNull;

                record.TotalNum   = num;
                record.Unit       = unit;
                record.Price      = price;
                record.TotalPrice = totalPrice;
                record.Comment    = comment;

                records.Add(record);
            }

            return(isInputCorrect);
        }
Ejemplo n.º 2
0
        //get and set api
        protected bool getCard(out Card c)
        {
            //先获取status
            int tempStatus = 1;

            if (card != null)
            {
                tempStatus = card.Status;
            }

            c = new Card();

            c.Status = tempStatus;

            c.ID = cardID;

            string code;

            if (ValidateUtility.getName(this.textBox_serial, this.errorProvider1, out code) == false)
            {
                return(false);
            }
            c.Code = code;

            int customerID = -1;

            if (this.lookupText1.Visible == true && ValidateUtility.getLookupValueID(this.lookupText1, this.errorProvider1, out customerID) == false)
            {
                return(false);
            }

            c.CustomerID = customerID;

            c.CardTime = this.dateTime_cardTime.Value;
            c.Comment  = this.textBox_comment.Text;
            c.Oper     = this.textBox_operator.Text;


            c.CustomerName = this.lookupText1.Text_Lookup;

            double total;
            int    num, leftNum;

            if (ValidateUtility.getDouble(this.textBox_realTotal, this.errorProvider1, true, true, out total) &&
                ValidateUtility.getInt(this.textBox_num, this.errorProvider1, true, true, out num) &&
                ValidateUtility.getInt(this.textBox_leftNum, this.errorProvider1, true, true, out leftNum))
            {
                c.Total      = total;
                c.Number     = num;
                c.LeftNumber = leftNum;
            }
            else
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        public override List <ProductCirculationRecord> FindList(int circulationID)
        {
            List <ProductCirculationRecord> records = new List <ProductCirculationRecord>();

            string    commandText = string.Format("select * from ProductStainlessCirculationRecord, ProductStainless where ProductStainlessCirculationRecord.productID = ProductStainless.ID and circulationID = {0} order by ProductStainlessCirculationRecord.ID", circulationID);
            DataTable dt          = DbHelperAccess.executeQuery(commandText);

            foreach (DataRow dr in dt.Rows)
            {
                bool tempBool = false;

                ProductStainlessCirculationRecord record = new ProductStainlessCirculationRecord();
                record.CirculationID = circulationID;
                record.ID            = (int)dr["ProductStainlessCirculationRecord.ID"];

                int    pieces;
                double price, totalPrice, quantityPerPiece;

                double.TryParse(dr["price"].ToString(), out price);
                record.Price = price;

                record.Serial      = dr["serial"].ToString();
                record.ProductID   = (int)dr["ProductStainless.ID"];
                record.ProductName = dr["name"].ToString();

                ValidateUtility.getDouble(dr, "ProductStainlessCirculationRecord.quantityPerPiece", out quantityPerPiece, out tempBool);
                record.QuantityPerPiece = quantityPerPiece;
                record.QuantityNull     = tempBool;

                ValidateUtility.getInt(dr, "pieces", out pieces, out tempBool);
                record.Pieces     = pieces;
                record.PiecesNull = tempBool;

                record.Unit = dr["ProductStainlessCirculationRecord.unit"].ToString();

                double num;
                ValidateUtility.getDouble(dr, "totalNum", out num, out tempBool);
                record.TotalNum = num;

                ValidateUtility.getDouble(dr, "totalPrice", out totalPrice, out tempBool);
                record.TotalPrice = totalPrice;

                record.Comment = dr["ProductStainlessCirculationRecord.comment"].ToString();

                records.Add(record);
            }
            return(records);
        }
Ejemplo n.º 4
0
        //get and set api
        protected bool getConsume(out Consume consume)
        {
            consume    = new Consume();
            consume.ID = consumeID;

            string code;

            if (ValidateUtility.getName(this.textBox_code, this.errorProvider1, out code) == false)
            {
                return(false);
            }
            consume.Code = code;

            int num = 1;

            if (ValidateUtility.getInt(this.textBox_num, this.errorProvider1, true, true, out num) == false)
            {
                return(false);
            }
            consume.Number = num;


            int cardID = -1;

            if (this.lookupText2.Visible == true && ValidateUtility.getLookupValueID(this.lookupText2, this.errorProvider1, out cardID) == false)
            {
                return(false);
            }

            consume.CardID = cardID;
            int leftNum = 0;

            int.TryParse(this.lookupText2.LookupArg.ArgName, out leftNum);
            consume.LeftNumber = leftNum;

            consume.ConsumeTime = this.dateTime_consumeTime.Value;
            consume.Comment     = this.textBox_comment.Text;
            consume.Oper        = this.textBox_operator.Text;

            return(true);
        }
Ejemplo n.º 5
0
        private bool getRecord(out ProductClothesCirculationRecord record)
        {
            record            = new ProductClothesCirculationRecord();
            record.SkuRecords = new List <ProductClothesCirculationSKURecord>();
            int totalNum = 0;

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                for (int j = 1; j < this.dataGridView1.Rows[i].Cells.Count; j++)
                {
                    int num = 0;
                    if (!ValidateUtility.getInt(this.dataGridView1[j, i], false, true, out num))
                    {
                        return(false);
                    }

                    if (num == 0)
                    {
                        continue;
                    }

                    ProductClothesCirculationSKURecord skuRecord = new ProductClothesCirculationSKURecord();
                    skuRecord.Num          = num;
                    skuRecord.ProductSKU   = ProductSKUDao.getInstance().FindByComposeID(productId, colorAttrs[i].CharactorValueId, sizeAttrs[j - 1].CharactorValueId);
                    skuRecord.ProductSKUID = skuRecord.ProductSKU.ID;

                    record.SkuRecords.Add(skuRecord);

                    totalNum += num;
                }
            }

            record.ProductID = ProductId;
            record.TotalNum  = totalNum;
            return(true);
        }
Ejemplo n.º 6
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            receipt = purchaseBack = otherReceipt = 0;
            payed   = sellBack = freights = otherPay = 0;

            payReceiptList  = PayReceiptDao.getInstance().FindPayReceiptList(null, null, 4, null, -1, 1);
            circulationList = ProductStainlessCirculationDao.getInstance().FindProductCirculationList(1, 4, null, null, 4, null, -1);

            foreach (ProductCirculation cir in circulationList)
            {
                int type = cir.Type;
                if (type == 1)
                {
                    payed += cir.ThisPayed;
                }
                else if (type == 2)
                {
                    purchaseBack += cir.ThisPayed;
                }
                else if (type == 3)
                {
                    receipt += cir.ThisPayed;
                }
                else if (type == 4)
                {
                    sellBack += cir.ThisPayed;
                }

                freights += cir.Freight;
            }

            foreach (PayReceipt pr in payReceiptList)
            {
                PayReceipt.BillType type = pr.bill_type;
                switch (type)
                {
                case PayReceipt.BillType.BuyPay:
                    payed += pr.thisPayed;
                    break;

                case PayReceipt.BillType.BuyRefund:
                    purchaseBack += pr.thisPayed;
                    break;

                case PayReceipt.BillType.SellReceipt:
                    receipt += pr.thisPayed;
                    break;

                case PayReceipt.BillType.SellRefund:
                    sellBack += pr.thisPayed;
                    break;

                case PayReceipt.BillType.OtherPay:
                    otherPay += pr.thisPayed;
                    break;

                case PayReceipt.BillType.OtherReceipt:
                    otherReceipt += pr.thisPayed;
                    break;

                default:
                    break;
                }
            }

            lib       = 0;
            productDT = ProductStainlessDao.getInstance().FindList(null, null, true);
            foreach (DataRow dr in productDT.Rows)
            {
                double price;
                int    num;
                bool   positive;

                ValidateUtility.getInt(dr, "num", out num, out positive);
                ValidateUtility.getDouble(dr, "priceCost", out price);
                //这里如果直接取ProductStainless就不需要判断
                if (price <= 0)
                {
                    ValidateUtility.getDouble(dr, "pricePurchase", out price);
                }

                lib = lib + price * num;
            }

            needPay    = needReceipt = 0;
            customerDT = CustomerDao.getInstance().FindList(null, null);

            foreach (DataRow dr in customerDT.Rows)
            {
                double arrear = 0;
                ValidateUtility.getDouble(dr, "arrear", out arrear);
                if (arrear > 0)
                {
                    needPay += arrear;
                }
                else
                {
                    needReceipt -= arrear;
                }
            }
        }