Пример #1
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("是否删除ID号为{0}的消费?", ids.ToString()), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (ConsumeDao.getInstance().FindByID(list[i]).Status > 1)
                    {
                        MessageBox.Show(string.Format("ID为{0}的消费已经审核, 无法删除!", list[i]), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        initList();
                        return;
                    }
                    ConsumeDao.getInstance().Delete(list[i]);
                }
                initList();
                MessageBox.Show("删除消费成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
        //对内提供服务的函数,调用switch mode,其实可以把openMode作为参数
        private void initCard()
        {
            //2020-1-18 这里只分两种情况,除了0之外,其他情况还要根据card的status来重设openMode
            if (openMode == 0)
            {
                int max = 1;// CirDao.getMaxCode(string.Format("CARD-{0}-", DateTime.Now.ToString("yyyyMMdd")));
                this.textBox_serial.Text     = string.Format("CARD-{0}-{1:0000}", DateTime.Now.ToString("yyyyMMdd"), max + 1);
                this.dateTime_cardTime.Value = DateTime.Now;
                this.textBox_num.Text        = "";
                this.textBox_realTotal.Text  = "";

                this.textBox_comment.Text    = null;
                this.textBox_operator.Text   = ConfDao.getInstance().Get(5).ToString();
                this.lookupText1.LookupArg   = null;
                this.lookupText1.Text_Lookup = null;
            }
            else
            {
                card = CardDao.getInstance().FindByID(cardID);

                this.textBox_serial.Text     = card.Code;
                this.dateTime_cardTime.Value = card.CardTime;
                this.textBox_realTotal.Text  = card.Total.ToString();
                this.textBox_num.Text        = card.Number.ToString();
                this.textBox_leftNum.Text    = card.LeftNumber.ToString();
                this.textBox_comment.Text    = card.Comment;
                this.textBox_operator.Text   = card.Oper;
                this.lookupText1.LookupArg   = new LookupArg(card.CustomerID, card.CustomerName);
                this.lookupText1.Text_Lookup = card.CustomerName;

                List <Consume> list = ConsumeDao.getInstance().FindList(cardID, 4);
                this.dataGridView1.Rows.Clear();

                for (int i = 0; i < list.Count; i++)
                {
                    Consume consume = list[i];
                    this.dataGridView1.Rows.Add();
                    this.dataGridView1.Rows[i].Cells["ID"].Value   = consume.ID;
                    this.dataGridView1.Rows[i].Cells["name"].Value = consume.Code;

                    this.dataGridView1.Rows[i].Cells["num"].Value = consume.Number;

                    int status = consume.Status;
                    this.dataGridView1.Rows[i].Cells["status"].Value = Consume.consumeStatusContext[status - 1];

                    this.dataGridView1.Rows[i].Cells["sellTime"].Value = consume.ConsumeTime.ToString("yyyy-MM-dd HH:mm:ss");
                }

                openMode = card.Status;
            }
            switchMode(openMode);
            resetNeedSave(false);
        }
Пример #3
0
        //对内提供服务的函数,如果是edit,会自动调整openMode,并调用switch mode
        private void initConsume()
        {
            //2020-1-18 这里只分两种情况,除了0之外,其他情况还要根据card的status来重设openMode
            if (openMode == 0)
            {
                int max = 1;// CirDao.getMaxCode(string.Format("CARD-{0}-", DateTime.Now.ToString("yyyyMMdd")));
                this.textBox_code.Text = string.Format("XF-{0}-{1:0000}", DateTime.Now.ToString("yyyyMMdd"), max + 1);

                this.dateTime_consumeTime.Value = DateTime.Now;
                this.textBox_comment.Text       = null;
                this.lookupText1.LookupArg      = null;
                this.lookupText1.Text_Lookup    = null;

                this.textBox_operator.Text = ConfDao.getInstance().Get(5).ToString();
                //this.dataGridView1.Rows.Clear();
                //this.dataGridView2[1, 0].Value = null;
            }
            else
            {
                consume = ConsumeDao.getInstance().FindByID(consumeID);

                this.textBox_code.Text          = consume.Code;
                this.dateTime_consumeTime.Value = consume.ConsumeTime;

                this.textBox_comment.Text  = consume.Comment;
                this.textBox_operator.Text = consume.Oper;


                int leftNumber = 0;
                //如果是为审核,那么需要定时更新
                if (openMode == 1)
                {
                    leftNumber = consume.Card.LeftNumber;
                }
                else
                {
                    leftNumber = consume.LeftNumber;
                }
                string cardInfo = consume.Card.getInfo(leftNumber);

                this.lookupText2.LookupArg = new LookupArg(consume.CardID, cardInfo);
                //借这个存放leftNumber;
                this.lookupText2.LookupArg.ArgName = leftNumber.ToString();
                this.lookupText2.Text_Lookup       = cardInfo;


                openMode = consume.Status;
            }
            switchMode(openMode);
            resetNeedSave(false);
        }
Пример #4
0
        //审核
        private void toolStripButton_finish_Click(object sender, EventArgs e)
        {
            string tips = "审核后将从卡里扣除次数,是否继续?";

            if (MessageBox.Show(tips, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            this.getConsume(out consume);
            consume = ConsumeDao.getInstance().FindByID(consumeID);
            //2018-4-20修复的bug
            if (consume == null)
            {
                MessageBox.Show("该消费已经被删除了。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Card card = consume.Card;

            if (consume.Number > card.LeftNumber)
            {
                MessageBox.Show("该消费次数超过剩余次数。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            consume.ConsumeTime = DateTime.Now;
            consume.LeftNumber  = card.LeftNumber;
            consume.Status      = 4;

            ConsumeDao.getInstance().Update(consume);
            card.LeftNumber = card.LeftNumber - consume.Number;
            if (card.LeftNumber == 0)
            {
                card.Status = 4;
            }

            CardDao.getInstance().Update(card);

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

            this.initConsume();
            this.invokeUpdateNotify(UpdateType.ConsumeUpdate);
            this.invokeUpdateNotify(UpdateType.CardUpdate);
        }
Пример #5
0
        private void initList()
        {
            List <Consume> list = ConsumeDao.getInstance().FindList(0, 0);

            this.dataGridView1.Rows.Clear();

            for (int i = 0; i < list.Count; i++)
            {
                Consume consume = list[i];
                this.dataGridView1.Rows.Add();
                this.dataGridView1.Rows[i].Cells["ID"].Value       = consume.ID;
                this.dataGridView1.Rows[i].Cells["name"].Value     = consume.Code;
                this.dataGridView1.Rows[i].Cells["customer"].Value = consume.CardID;

                /*int type = (int)(dr["type"]);
                 * this.dataGridView1.Rows[index].Cells["type"].Value = ProductCirculation.CirculationTypeConfs[type - 1].name;
                 * this.dataGridView1.Rows[index].Cells["typeValue"].Value = type;*/

                this.dataGridView1.Rows[i].Cells["num"].Value = consume.Number;

                int leftNum = 0;

                int status = consume.Status;
                this.dataGridView1.Rows[i].Cells["status"].Value = Consume.consumeStatusContext[status - 1];
                if (status == 1)
                {
                    this.dataGridView1.Rows[i].Cells["status"].Style.ForeColor          = Color.Red;
                    this.dataGridView1.Rows[i].Cells["status"].Style.SelectionForeColor = Color.Red;

                    leftNum = consume.Card.LeftNumber;
                }
                else
                {
                    this.dataGridView1.Rows[i].Cells["status"].Style.ForeColor          = Color.Black;
                    this.dataGridView1.Rows[i].Cells["status"].Style.SelectionForeColor = Color.Black;

                    leftNum = consume.LeftNumber;
                }
                this.dataGridView1.Rows[i].Cells["cardInfo"].Value = consume.Card.getInfo(leftNum);

                this.dataGridView1.Rows[i].Cells["sellTime"].Value = consume.ConsumeTime.ToString("yyyy-MM-dd HH:mm:ss");
            }
        }
Пример #6
0
        /// <summary>
        /// for event
        /// </summary>
        ///
        protected void toolStripButton_save_Click(object sender, EventArgs e)
        {
            bool isSellCorrect = getConsume(out consume);

            if (isSellCorrect == false)
            {
                return;
            }

            consume.Status = 1;

            if (this.openMode == 1 && ConsumeDao.getInstance().FindByID(consumeID) == null)
            {
                MessageBox.Show("该消费已经被删除了。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                if (openMode == 0)
                {
                    ConsumeDao.getInstance().Insert(consume, out consumeID);
                    MessageBox.Show(string.Format("增加{0}成功!", this.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    openMode = 1;
                }
                else if (openMode == 1)
                {
                    ConsumeDao.getInstance().Update(consume);
                    MessageBox.Show(string.Format("保存{0}成功!", this.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                //主要是保存按钮回到原来的状态
                this.initConsume();
            }
            catch (Exception ex)
            {
                /*if (openMode == 0)
                 *  ConsumeDao.getInstance().DeleteByID(consumeID);*/
                MessageBox.Show("保存有误,可能是往来单位或卡片被修改过,请重新编辑!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            this.invokeUpdateNotify(UpdateType.ConsumeUpdate);
        }
Пример #7
0
        //弃核
        private void toolStripButton_finishCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否弃核,退回到未审核状态?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            if (ConsumeDao.getInstance().FindList(cardID, 0).Count > 0)
            {
                MessageBox.Show("弃核失败,该卡片已经消费过,请先删除相应的消费。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            card.Status   = 1;
            card.CardTime = DateTime.Now;

            CardDao.getInstance().Update(card);

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

            this.initCard();

            this.invokeUpdateNotify(UpdateType.CardUpdate);
        }
Пример #8
0
        //弃核
        private void toolStripButton_finishCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否弃核,退回到未审核状态?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            List <Consume> cons = ConsumeDao.getInstance().FindList(consume.CardID, 0);

            if (cons[cons.Count - 1].ID > consume.ID)
            {
                MessageBox.Show("弃核失败,该卡片后面还有消费,请先删除相应的消费。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            consume.Status      = 1;
            consume.ConsumeTime = DateTime.Now;
            ConsumeDao.getInstance().Update(consume);

            //注意这里,这样合不合理,如果通过dao find出来就没问题,如果是this.getConsume就不行,getConsume后,还是重新find一下,这样就没问题
            Card card = consume.Card;

            if (card.LeftNumber == 0)
            {
                card.Status = 3;
            }
            card.LeftNumber += consume.Number;

            CardDao.getInstance().Update(card);

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

            this.initConsume();

            this.invokeUpdateNotify(UpdateType.CardUpdate);
            this.invokeUpdateNotify(UpdateType.ConsumeUpdate);
        }