Esempio n. 1
0
        private void 全部数据清空ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("数据将全部被清除,建议先备份数据文件后再清除,是否备份?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                导出数据文件ToolStripMenuItem_Click(null, null);
            }
            else if (result == DialogResult.No)
            {
                if (MessageBox.Show("现有数据将全部被清除,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                {
                    return;
                }
                else
                {
                    CustomerDao.getInstance().ClearAllArrear();
                    PayReceiptDao.getInstance().DeleteAll();
                    ProductStainlessCirculationDao.getInstance().DeleteAll();
                    SellProfitDao.getInstance().DeleteAll();
                    ProductStainlessDao.getInstance().ClearAllNumAndCost();
                    MessageBox.Show("删除清空数据成功,系统将自动关闭,请重新启动软件!", "提示", MessageBoxButtons.OK);
                    this.Close();
                }
            }
        }
Esempio n. 2
0
        //del
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            List <int> list = this.dataGridView1.getSelectIDs("ID", "check");

            if (list == null || list.Count <= 0)
            {
                MessageBox.Show("请选择款单", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            StringBuilder ids = new StringBuilder();

            for (int ii = 0; ii < list.Count; ii++)
            {
                ids.Append(list[ii]);
                ids.Append(" ");
            }
            if (MessageBox.Show(string.Format("是否删除流水号为{0}的款单?", ids.ToString()), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (PayReceiptDao.getInstance().FindByID(list[i]).status > 1)
                    {
                        MessageBox.Show(string.Format("ID为{0}的款单已经审核, 无法删除!", list[i]), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        initList();
                        return;
                    }
                    PayReceiptDao.getInstance().Delete(list[i]);
                }
                initList();
                MessageBox.Show("删除款单成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int parentId = (int)e.Argument;

            payReceiptList = PayReceiptDao.getInstance().FindPayReceiptList(this.dateTimePicker_start.Value, this.dateTimePicker_end.Value.AddDays(1), 4, this.textBox_search.Text, parentId, 1);
            //这个地方需要再改成ProductCirculationDao
            productCirculationList = ProductStainlessCirculationDao.getInstance().FindProductCirculationList(1, 4, this.dateTimePicker_start.Value, this.dateTimePicker_end.Value.AddDays(1), 4, this.textBox_search.Text, parentId);
        }
Esempio n. 4
0
        /// <summary>
        /// for event
        /// </summary>
        ///
        protected virtual void toolStripButton_save_Click(object sender, EventArgs e)
        {
            //2018-3-30:防止其他窗口有更新
            this.refreshArrears();

            PayReceipt payReceipt;
            //get的时候没有status
            bool isCorrect = getPayReceipt(out payReceipt);

            if (isCorrect == false)
            {
                return;
            }

            if (this.openMode == 1 && PayReceiptDao.getInstance().FindByID(payReceipt.id) == null)
            {
                MessageBox.Show("该单据已经被删除了。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                if (openMode == 0)
                {
                    payReceipt.status = 1;
                    PayReceiptDao.getInstance().Insert(payReceipt, out payReceiptID);
                    MessageBox.Show(string.Format("增加{0}成功!", this.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (openMode == 1)
                {
                    payReceipt.status = 1;
                    PayReceiptDao.getInstance().Update(payReceipt);
                    MessageBox.Show(string.Format("保存{0}成功!", this.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                openMode = 1;
                this.initPayReceipt();
            }
            catch (Exception ex)
            {
                if (openMode == 0)
                {
                    PayReceiptDao.getInstance().Delete(payReceiptID);
                }
                MessageBox.Show("保存有误,可能是往来单位被修改过,请重新编辑!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            //so important: if edit ,it should be refresh also, because edit will del exist item and add new item

            this.invokeUpdateNotify(conf.notifyType);
        }
Esempio n. 5
0
        /// <summary>
        /// for init circulation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void initPayReceipt()
        {
            if (openMode == 0)
            {
                switchMode(openMode);
                int max = PayReceiptDao.getInstance().getMaxCode(conf.serial);
                this.textBox_serial.Text     = string.Format("{0}-{1}-{2:0000}", conf.serial, DateTime.Now.ToString("yyyyMMdd"), max + 1);
                this.lookupText1.LookupArg   = null;
                this.lookupText1.Text_Lookup = null;
                this.dateTime_time.Value     = DateTime.Now;
                this.textBox_operator.Text   = null;

                this.textBox_sum.Text             = null;
                this.textBox_previousArrears.Text = null;
                this.textBox_thisPayed.Text       = null;
                this.textBox_accumulative.Text    = null;

                this.textBox_comment.Text = null;

                this.resetNeedSave(false);

                return;
            }

            payReceipt = PayReceiptDao.getInstance().FindByID(payReceiptID);

            this.textBox_serial.Text   = payReceipt.serial;
            this.dateTime_time.Value   = payReceipt.bill_time;
            this.textBox_comment.Text  = payReceipt.comment;
            this.textBox_operator.Text = payReceipt.handle_people;

            this.textBox_sum.Text = payReceipt.amount.ToString();

            this.lookupText1.LookupArg   = new LookupArg(payReceipt.customer_id, payReceipt.customerName);
            this.lookupText1.Text_Lookup = payReceipt.customerName;

            //如果是未审核状态,以前欠款应该如何生成?
            if (payReceipt.status > 1)
            {
                this.textBox_previousArrears.Text = payReceipt.previousArrears.ToString();
            }

            this.textBox_thisPayed.Text = payReceipt.thisPayed.ToString();

            openMode = payReceipt.status;

            this.resetNeedSave(false);
            this.switchMode(payReceipt.status);
        }
        //弃核
        protected override void toolStripButton_finishCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否弃核,退回到未审核状态?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            PayReceiptDao.getInstance().UpdateStatus(this.payReceipt.id, 1);

            MessageBox.Show("弃核成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            openMode = 1;
            this.switchMode(1);

            this.invokeUpdateNotify(this.conf.finishNotifyType);
        }
Esempio n. 7
0
        //审核
        protected virtual void toolStripButton_finish_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("审核后,将修改相关债务信息,是否审核?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            //2017-11-20
            this.refreshArrears();

            //要重新get一下,因为债务有可能更新。
            PayReceipt payReceipt;
            bool       isCorrect = getPayReceipt(out payReceipt);

            if (isCorrect == false)
            {
                return;
            }

            if (PayReceiptDao.getInstance().FindByID(payReceipt.id) == null)
            {
                MessageBox.Show("该单据已经被删除了。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            payReceipt.bill_time     = DateTime.Now;
            this.dateTime_time.Value = payReceipt.bill_time;
            //重置了dateTime控件后,neeSave会变为true,但是由于是系统自动更新时间,所以不需要用户保存!耦合度太高了
            this.needSave = false;

            payReceipt.status = 4;
            PayReceiptDao.getInstance().Update(payReceipt);
            CustomerDao.getInstance().update_arrear(payReceipt.customer_id, conf.arrearDirection * Convert.ToDouble(this.textBox_accumulative.Text));
            this.initPayReceipt();

            MessageBox.Show("审核成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            openMode = 4;
            this.switchMode(4);

            this.invokeUpdateNotify(conf.finishNotifyType);
        }
        //审核
        protected override void toolStripButton_finish_Click(object sender, EventArgs e)
        {
            PayReceipt payReceipt;
            bool       isCorrect = getPayReceipt(out payReceipt);

            if (isCorrect == false)
            {
                return;
            }

            payReceipt.status = 4;
            PayReceiptDao.getInstance().Update(payReceipt);
            //CustomerDao.getInstance().update_arrear(payReceipt.customer_id, this.arrearDirection * Convert.ToDouble(this.textBox_accumulative.Text));
            MessageBox.Show("审核成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            openMode = 4;
            this.switchMode(4);

            this.invokeUpdateNotify(conf.finishNotifyType);
        }
Esempio n. 9
0
        //弃核
        protected virtual void toolStripButton_finishCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否弃核,退回到未审核状态?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            PayReceipt maxPr = PayReceiptDao.getInstance().FindLastestByCustomerID(this.payReceipt.customer_id, false);

            if (maxPr != null && !maxPr.serial.Equals(this.payReceipt.serial))
            {
                MessageBox.Show(string.Format("弃核失败,在此单之后存在已审核的单据,请先弃核{0}", maxPr.serial), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            ProductCirculation pc = cirDao.FindLastestByCustomerID(this.payReceipt.customer_id, false);

            if (pc != null && pc.CirculationTime > payReceipt.bill_time)
            {
                MessageBox.Show(string.Format("弃核失败,在此单之后存在已审核的单据,请先弃核{0}", pc.Code), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //直接取以前的欠款,简单
            double arrear;

            double.TryParse(this.textBox_previousArrears.Text, out arrear);

            CustomerDao.getInstance().update_arrear(this.payReceipt.customer_id, this.conf.arrearDirection * arrear);
            PayReceiptDao.getInstance().UpdateStatus(this.payReceipt.id, 1);

            MessageBox.Show("弃核成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            openMode = 1;
            this.switchMode(1);

            this.invokeUpdateNotify(this.conf.finishNotifyType);
        }
Esempio n. 10
0
        private void generatePayReceipt(double arrearDif, double previousArrear, int customerID)
        {
            PayReceipt payReceipt = new PayReceipt();

            payReceipt.bill_type       = PayReceipt.BillType.ChangeArrear;
            payReceipt.bill_time       = DateTime.Now;
            payReceipt.cashDirection   = arrearDif > 0 ? -1 : 1;
            payReceipt.arrearDirection = previousArrear + arrearDif > 0 ? 1 : -1;

            int max = PayReceiptDao.getInstance().getMaxCode("QKTZ");

            payReceipt.serial = string.Format("{0}-{1}-{2:0000}", "QKTZ", DateTime.Now.ToString("yyyyMMdd"), max + 1);

            payReceipt.customer_id = customerID;

            payReceipt.amount = Math.Abs(arrearDif);
            //previousArrear用的是正数表示
            payReceipt.previousArrears = Math.Round(previousArrear * payReceipt.arrearDirection, 2);

            payReceipt.status  = 4;
            payReceipt.comment = "修改欠款数据时自动生成";
            PayReceiptDao.getInstance().Insert(payReceipt, out payReceipt.id);
        }
Esempio n. 11
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;
                }
            }
        }
        //弃核
        private void toolStripButton_finishCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否弃核,退回到未审核状态?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            //判断是否支持负库存
            string negative = ConfDao.getInstance().Get(20);

            if ((string.IsNullOrEmpty(negative) || negative != "1") && conf.productDirection == 1)
            {
                foreach (ProductCirculationRecord record in records)
                {
                    int leftNum = cirDao.getProductDao().FindNumByID(record.ProductID);
                    if (record.TotalNum > leftNum)
                    {
                        MessageBox.Show(string.Format("{0} 库存不足,数量为{1},弃核失败!", record.ProductName, leftNum), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Enabled = true;
                        return;
                    }
                }
            }

            //circulation不用重新get,因为考虑到审核过的有重新init,而且其值不能改变
            ProductCirculation maxCir = cirDao.FindLastestByCustomerID(this.circulation.CustomerID, false);

            if (maxCir != null && !maxCir.Code.Equals(circulation.Code))
            {
                MessageBox.Show(string.Format("弃核失败,在此单之后存在已审核的单据,请先弃核{0}", maxCir.Code), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            PayReceipt payReceipt = PayReceiptDao.getInstance().FindLastestByCustomerID(circulation.CustomerID, false);

            if (payReceipt != null && circulation.CirculationTime < payReceipt.bill_time)
            {
                MessageBox.Show(string.Format("弃核失败,在此单之后存在已审核的单据,请先弃核{0}", payReceipt.serial), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            foreach (ProductCirculationRecord record in records)
            {
                //更新产品数量
                this.cancelUpdateCostAndProfit(circulation, record);
            }

            double arrear;

            double.TryParse(this.textBox_previousArrears.Text, out arrear);

            CustomerDao.getInstance().update_arrear(circulation.CustomerID, conf.arrearsDirection * arrear);
            cirDao.UpdateStatus(circulationID, 1);

            MessageBox.Show("弃核成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            openMode = 1;
            this.switchMode(1);

            this.invokeUpdateNotify(this.conf.finishNotifyType);
        }
        private void setLastPayReceipt(int customerId)
        {
            ProductCirculation cir            = cirDao.FindLastestByCustomerID(customerId, true);
            PayReceipt         payReceipt     = PayReceiptDao.getInstance().FindLastestByCustomerID(customerId, true);
            double             lastPayReceipt = 0;
            int      cashDirection            = 0;
            DateTime dt = DateTime.Now;

            if (cir != null && payReceipt != null)
            {
                if (cir.CirculationTime < payReceipt.bill_time)
                {
                    lastPayReceipt = payReceipt.thisPayed;
                    cashDirection  = payReceipt.cashDirection;
                    dt             = payReceipt.bill_time;
                }
                else
                {
                    lastPayReceipt = cir.ThisPayed;
                    cashDirection  = cir.FlowType * -1;
                    dt             = cir.CirculationTime;
                }
            }
            else if (cir != null && payReceipt == null)
            {
                lastPayReceipt = cir.ThisPayed;
                cashDirection  = cir.FlowType * -1;
                dt             = cir.CirculationTime;
            }
            else if (cir == null && payReceipt != null)
            {
                lastPayReceipt = payReceipt.thisPayed;
                cashDirection  = payReceipt.cashDirection;
                dt             = payReceipt.bill_time;
            }

            if (lastPayReceipt == 0 || cashDirection == 0)
            {
                label_lastPayReceipt.Text = "";
            }
            else
            {
                label_lastPayReceipt.Text = string.Format("{0}{1:0.00}元({2:yyyy/MM/dd})", cashDirection == -1 ? LabelUtility.LAST_PAY : LabelUtility.LAST_RECEIPT, lastPayReceipt, dt);
            }

            Customer customer = CustomerDao.getInstance().FindByID(customerId);

            if (customer.arrear < 0)
            {
                ProductCirculation lastCir = cirDao.FindLastestAccReceiptZero(customerId);
                PayReceipt         lastPay = PayReceiptDao.getInstance().FindLastestAccReceiptZero(customerId);
                DateTime           lastDt;
                if (lastCir != null && lastPay != null)
                {
                    lastDt = lastCir.CirculationTime.CompareTo(lastPay.bill_time) < 0 ? lastCir.CirculationTime : lastPay.bill_time;
                }
                else if (lastCir == null && lastPay != null)
                {
                    lastDt = lastPay.bill_time;
                }
                else if (lastCir != null && lastPay == null)
                {
                    lastDt = lastCir.CirculationTime;
                }
                else
                {
                    return;
                }


                TimeSpan ts = DateTime.Now.Subtract(lastDt);
                label_lastPayReceipt.Text += string.Format("欠款{0}天", ts.Days);
            }
        }
Esempio n. 14
0
        private void initList()
        {
            try
            {
                List <PayReceipt> prList = PayReceiptDao.getInstance().FindPayReceiptList(this.dateTimePicker3.Value, this.dateTimePicker4.Value.AddDays(1), (int)(comboBox1.SelectedValue), textBox_customer.Text.Trim(), -1, 0);
                this.dataGridView1.Rows.Clear();

                int    index = 0;
                double sum   = 0;

                foreach (PayReceipt pr in prList)
                {
                    index = this.dataGridView1.Rows.Add();
                    this.dataGridView1.Rows[index].Cells["ID"].Value       = pr.id;
                    this.dataGridView1.Rows[index].Cells["code"].Value     = pr.serial;
                    this.dataGridView1.Rows[index].Cells["customer"].Value = pr.customerName;
                    int type = (int)pr.bill_type;

                    this.dataGridView1.Rows[index].Cells["type"].Value      = PayReceipt.PayReceiptTypeConfs[type - 1].name;
                    this.dataGridView1.Rows[index].Cells["typeValue"].Value = type;

                    double pay = pr.thisPayed;
                    if (type == 1 || type == 4 || type == 5)
                    {
                        ControlUtility.setCellWithColor(dataGridView1.Rows[index].Cells["sum"], Color.Green, string.Format("-{0:0.00}", pay));
                        sum -= pay;
                    }
                    else if (type == 2 || type == 3 || type == 6)
                    {
                        ControlUtility.setCellWithColor(dataGridView1.Rows[index].Cells["sum"], Color.Red, string.Format("+{0:0.00}", pay));
                        sum += pay;
                    }

                    int status = pr.status;
                    if (status == 1)
                    {
                        ControlUtility.setCellWithColor(this.dataGridView1.Rows[index].Cells["status"], Color.Red, PayReceipt.statusContext[status - 1]);
                    }
                    else
                    {
                        ControlUtility.setCellWithColor(this.dataGridView1.Rows[index].Cells["status"], Color.Black, PayReceipt.statusContext[status - 1]);
                    }

                    this.dataGridView1.Rows[index].Cells["time"].Value = pr.bill_time.ToString("yyyy-MM-dd HH:mm:ss");
                }

                index = this.dataGridView1.Rows.Add();

                this.dataGridView1.Rows[index].Cells["code"].Value        = "合计";
                this.dataGridView1.Rows[index].Cells["sum"].Value         = sum.ToString("+0.00;-0.00;0");
                this.dataGridView1.Rows[index].DefaultCellStyle.ForeColor = Color.Red;
                if (sum >= 0)
                {
                    this.dataGridView1.Rows[index].Cells["sum"].Style.ForeColor = Color.Red;
                }
                else
                {
                    this.dataGridView1.Rows[index].Cells["sum"].Style.ForeColor = Color.Green;
                }
                this.dataGridView1.Rows[index].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                this.dataGridView1.Rows[index].DefaultCellStyle.Font      = new Font("宋体", 10F, FontStyle.Bold);
            }
            catch (Exception ex)
            {
                //MessageBox.Show("查询错误, 请输入正确的条件.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }