Пример #1
0
        private bool getProduct(out ProductStainless product)
        {
            double price_purchase, price_sell, price_cost, num, quantityPerPiece;
            string name;
            int    categoryID;

            if (ValidateUtility.getName(this.textBox_name, this.errorProvider1, out name) &&
                ValidateUtility.getDouble(this.textBox_purchasePrice, this.errorProvider1, true, true, out price_purchase) &&
                ValidateUtility.getDouble(this.textBox_sellPrice, this.errorProvider1, true, true, out price_sell) &&
                ValidateUtility.getDouble(this.textBox_cost, this.errorProvider1, false, false, out price_cost) &&
                ValidateUtility.getDouble(this.textBox_quantityPerPiece, this.errorProvider1, false, true, out quantityPerPiece) &&
                ValidateUtility.getDouble(this.textBox_libNum, this.errorProvider1, false, false, out num) &&
                this.getCategoryID(out categoryID))
            {
                product    = new ProductStainless(this.textBox_serial.Text, name, categoryID, price_purchase, price_sell, this.comboBox_unit.Text, quantityPerPiece, this.textBox_comment.Text, this.radioButton2.Checked);
                product.ID = productID;
                //2018-4-16修正bug
                product.PriceCost = price_cost;
                product.Num       = num;
                return(true);
            }
            else
            {
                product = null;
                return(false);
            }
        }
Пример #2
0
        public Card getBeanFromDataRow(DataRow dr)
        {
            Card card = new Card();

            if (dr != null)
            {
                card.ID         = (int)dr["Card.ID"];
                card.Code       = dr["code"] as string;
                card.CardTime   = (DateTime)dr["cardTime"];
                card.CustomerID = (int)dr["customerID"];
                double total = 0;
                ValidateUtility.getDouble(dr, "total", out total);
                card.Total        = total;
                card.Number       = (int)dr["num"];
                card.LeftNumber   = (int)dr["leftNum"];
                card.Comment      = dr["Card.comment"] as string;
                card.Oper         = dr["operator"] as string;
                card.Status       = (int)dr["status"];
                card.Type         = (int)dr["type"];
                card.CustomerName = dr["name"] as string;

                return(card);
            }
            return(null);
        }
        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);
        }
        /// <summary>
        /// set datagridview value
        /// </summary>
        /// <param name="rowIndex"></param>
        protected virtual void setSubTotalPrice(int rowIndex)
        {
            DataGridViewRow row = this.dataGridView1.Rows[rowIndex];
            double          price, num;

            ValidateUtility.getDouble(row.Cells["price"], out price);
            ValidateUtility.getDouble(row.Cells["num"], false, true, out num);
            row.Cells["totalPrice"].Value = num * price;
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
0
        public override void initRecords(DataGridView dataGridView1, DataTable dataTable)
        {
            dataGridView1.Rows.Clear();
            double sumToPay = 0, sumToRecepit = 0;
            int    index = 0;

            foreach (DataRow dr in dataTable.Rows)
            {
                index = dataGridView1.Rows.Add();
                dataGridView1.Rows[index].Cells["ID"].Value       = dr["Customer.ID"];
                dataGridView1.Rows[index].Cells["name"].Value     = dr["Customer.name"];
                dataGridView1.Rows[index].Cells["category"].Value = dr["CustomerCategory.name"];
                double arrear = 0;
                bool   temp;
                ValidateUtility.getDouble(dr, "arrear", out arrear, out temp);
                if (arrear > 0)
                {
                    dataGridView1.Rows[index].Cells["myArrear"].Style.ForeColor          = Color.Green;
                    dataGridView1.Rows[index].Cells["myArrear"].Style.SelectionForeColor = Color.Green;
                    dataGridView1.Rows[index].Cells["myArrear"].Value = string.Format("{0:0.00}", arrear);
                    sumToPay += arrear;
                }
                else if (arrear < 0)
                {
                    dataGridView1.Rows[index].Cells["hisArrear"].Style.ForeColor          = Color.Red;
                    dataGridView1.Rows[index].Cells["hisArrear"].Style.SelectionForeColor = Color.Red;
                    dataGridView1.Rows[index].Cells["hisArrear"].Value = string.Format("{0:0.00}", -arrear);
                    sumToRecepit += (-arrear);
                }
            }

            index = dataGridView1.Rows.Add();

            dataGridView1.Rows[index].Cells["name"].Value = "合计";

            dataGridView1.Rows[index].Cells["myArrear"].Style.ForeColor          = Color.Green;
            dataGridView1.Rows[index].Cells["myArrear"].Style.SelectionForeColor = Color.Green;
            dataGridView1.Rows[index].Cells["myArrear"].Value = string.Format("{0:0.00}", sumToPay);

            dataGridView1.Rows[index].Cells["hisArrear"].Style.ForeColor          = Color.Red;
            dataGridView1.Rows[index].Cells["hisArrear"].Style.SelectionForeColor = Color.Red;
            dataGridView1.Rows[index].Cells["hisArrear"].Value = string.Format("{0:0.00}", sumToRecepit);

            dataGridView1.Rows[index].DefaultCellStyle.ForeColor = Color.Red;
            dataGridView1.Rows[index].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Rows[index].DefaultCellStyle.Font      = new Font("宋体", 10F, FontStyle.Bold);
        }
        //这个函数是更新下cutoff
        private void textBox_realTotal_TextChanged(object sender, EventArgs e)
        {
            this.realTotalNeedRecaculate = false;
            if (this.cutoffNeedReCaculate == true)
            {
                double realTotal = 0, total = 0, totalBackFreight = 0;
                double.TryParse(this.textBox_realTotal.Text, out realTotal);
                double.TryParse(this.label_totalBackFreight.Text, out totalBackFreight);

                ValidateUtility.getDouble(this.dataGridView2[1, 0], out total);
                if (total != 0)
                {
                    this.textBox_cutoff.Text = string.Format("{0}", (realTotal + totalBackFreight) / total * 100);
                }
            }
            this.realTotalNeedRecaculate = true;
        }
        protected override void setSubTotalPrice(int rowIndex)
        {
            DataGridViewRow row = this.dataGridView1.Rows[rowIndex];
            double          price;
            double          num = 0;

            ValidateUtility.getDouble(row.Cells["price"], out price);
            try
            {
                object temp = (row.Cells["num"] as DataGridViewLookupCell).EditedValue;
                num = ((temp as LookupArg).Value as ProductCirculationRecord).TotalNum;
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            row.Cells["totalPrice"].Value = num * price;
        }
Пример #10
0
        /// <summary>
        /// for get value from controls
        /// </summary>
        //没有获取status
        protected bool getPayReceipt(out PayReceipt payReceipt)
        {
            payReceipt               = new PayReceipt();
            payReceipt.id            = this.payReceiptID;
            payReceipt.bill_type     = conf.type;
            payReceipt.bill_time     = this.dateTime_time.Value;
            payReceipt.handle_people = textBox_operator.Text;
            payReceipt.comment       = textBox_comment.Text;

            payReceipt.cashDirection   = conf.cashDirection;
            payReceipt.arrearDirection = conf.arrearDirection;

            string name;

            if (ValidateUtility.getName(this.textBox_serial, this.errorProvider1, out name) == false)
            {
                return(false);
            }
            payReceipt.serial = name;

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

            double sum = 0, pay, previousArrears;

            if ((this.panel_sum.Visible == false || ValidateUtility.getDouble(this.textBox_sum, this.errorProvider1, true, true, out sum))
                //如果是退点,本单付款就不是必填,否则为必填
                && (this.label_pay_need.Visible == true && ValidateUtility.getDouble(this.textBox_thisPayed, this.errorProvider1, true, true, out pay) || this.label_pay_need.Visible == false && ValidateUtility.getDouble(this.textBox_thisPayed, this.errorProvider1, false, true, out pay)) &&
                ValidateUtility.getDouble(this.textBox_previousArrears, this.errorProvider1, false, false, out previousArrears))
            {
                payReceipt.amount = sum;
                //欠款用的是呈现给用户看得,一般为正数
                payReceipt.previousArrears = previousArrears;
                payReceipt.thisPayed       = pay;
            }
            else
            {
                return(false);
            }

            return(true);
        }
Пример #11
0
        //总价、折扣、退运费和实价的关系,有三种情况:
        //1,总价有变化,联合折扣、退运费计算出实价
        //2,折扣或退运费有变化,计算出实价
        //3,实价有变化,反推出折扣
        //1和2其实属于一种情况, 可以理解为正方向的计算,3可以理解为反方向的计算

        //这是明细改动时,更新总价,也是第1种情况
        protected void setTotalPrice()
        {
            double total = 0;

            double totalPieces = 0;

            int number = this.dataGridView1.RowCount;

            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {
                double totalPrice = 0;
                ValidateUtility.getDouble(row.Cells["totalPrice"], out totalPrice);
                total += totalPrice;

                double pieces = 0;
                ValidateUtility.getDouble(row.Cells["pieces"], out pieces);
                totalPieces += pieces;
            }

            this.dataGridView2[1, 0].Value = total;
            this.label_totalPieces.Text    = totalPieces == 0 ? "" : totalPieces.ToString();

            /*
             * double cutoff = 100;
             * double.TryParse(this.textBox_cutoff.Text, out cutoff);
             *
             * double backFreightPerPiece = 0;
             * double.TryParse(this.textBox_backFreightPerPiece.Text, out backFreightPerPiece);*/

            //added on 2018-3-16,这个是明细修改引起的总价重新计算
            //不需要通过realTotal引发重新计算cutoff,也不需要通过backFreight引发重新计算realTotal
            this.cutoffNeedReCaculate = false;
            //this.realTotalNeedRecaculate = false;

            /*this.label_totalBackFreight.Text = backFreightPerPiece * totalPieces;
             * double realTotal = total * cutoff / 100 - backFreightPerPiece * totalPieces;
             * this.textBox_realTotal.Text =realTotal.ToString();*/
            this.calTotalBackAndRealTotal();

            //added on 2018-3-16
            this.cutoffNeedReCaculate = true;
            //this.realTotalNeedRecaculate = true;
        }
Пример #12
0
        private bool getCustomer(out Customer customer)
        {
            string name;
            int    categoryID;
            double arrear;

            bool isNameCorrect     = ValidateUtility.getName(this.textBox_name, this.errorProvider1, out name);
            bool isCategoryCorrect = this.getCategoryID(out categoryID);
            bool isArrearCorrent   = ValidateUtility.getDouble(this.textBox_arrear, this.errorProvider1, false, false, out arrear);

            if (isNameCorrect && isCategoryCorrect && isArrearCorrent)
            {
                customer = new Customer(name, this.textBox_comment.Text, this.textBox_tel.Text,
                                        this.textBox_phone.Text, this.textBox_address.Text, categoryID, arrear);
                customer.ID = customerID;
                return(true);
            }
            else
            {
                customer = null;
                return(false);
            }
        }
Пример #13
0
        public Customer getBeanFromDataRow(DataRow dr)
        {
            Customer customer = new Customer();

            if (dr != null)
            {
                customer.ID     = (int)dr["ID"];
                customer.Parent = (int)dr["parent"];

                customer.Name    = dr["name"] as string;
                customer.Comment = dr["comment"] as string;
                customer.Tel     = dr["tel"] as string;
                customer.Phone   = dr["phone"] as string;
                customer.Address = dr["address"] as string;

                double arrear, receipt;
                ValidateUtility.getDouble(dr, "arrear", out arrear);
                customer.arrear = arrear;

                return(customer);
            }
            return(null);
        }
Пример #14
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;
                }
            }
        }
Пример #15
0
        protected bool getCirculation(out ProductCirculation circulation)
        {
            circulation                 = new ProductCirculation();
            circulation.ID              = circulationID;
            circulation.Type            = (int)conf.type;
            circulation.FlowType        = conf.productDirection;
            circulation.ArrearDirection = conf.arrearsDirection;

            string name;

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

            int customerID = -1;

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

            circulation.CustomerID = customerID;

            circulation.CirculationTime = this.dateTime_sellTime.Value;
            circulation.Comment         = this.textBox_comment.Text;
            circulation.Oper            = this.textBox_operator.Text;
            circulation.LastPayReceipt  = this.label_lastPayReceipt.Text;

            if (dataGridView2[1, 0].Value == null || dataGridView2[1, 0].Value.ToString() == "")
            {
                circulation.Total = 0;
            }
            else
            {
                circulation.Total = (double)dataGridView2[1, 0].Value;
            }

            circulation.CustomerName = this.lookupText1.Text_Lookup;

            double total, backFreightPerPiece, cutoff, realTotal, previousArrears, thisPayed, freight;

            if (ValidateUtility.getPrice(this.dataGridView2[1, 0], true, out total) &&
                ValidateUtility.getDouble(this.textBox_cutoff, this.errorProvider1, false, true, out cutoff) &&
                ValidateUtility.getPrice(this.textBox_backFreightPerPiece, this.errorProvider1, false, true, out backFreightPerPiece) &&
                ValidateUtility.getPrice(this.textBox_realTotal, this.errorProvider1, true, true, out realTotal) &&
                ValidateUtility.getPrice(this.textBox_previousArrears, this.errorProvider1, false, false, out previousArrears) &&
                ValidateUtility.getPrice(this.textBox_thisPayed, this.errorProvider1, false, true, out thisPayed) &&
                ValidateUtility.getPrice(this.textBox_freight, this.errorProvider1, false, true, out freight))
            {
                circulation.Total = total;
                circulation.BackFreightPerPiece = backFreightPerPiece;
                circulation.RealTotal           = realTotal;
                circulation.PreviousArrears     = previousArrears;
                circulation.ThisPayed           = thisPayed;
                circulation.Freight             = freight;
            }
            else
            {
                return(false);
            }

            return(true);
        }