Exemplo n.º 1
0
        private int UpdateByLines(string txt, Inputmode inputMode)
        {
            int    count = 0;                       //成功记录数
            string str   = txtInput.Text.TrimEnd(); //去掉最后的\r\n

            string[] lines        = str.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            bool     updateSingle = !(lines.Length > 20); //多行模式下设置显示更新模式

            if (inputMode == Inputmode.Single)
            {
                VisaInfo model = GetModelByLine(lines[lines.Length - 1]);
                if (model == null)
                {
                    MessageBoxEx.Show(Resources.FindModelFailedPleaseCheckInfoCorrect);
                    return(count);
                }

                UpdateModelState(model, _outState);
                if (!bll.Update(model))
                {
                    MessageBoxEx.Show(Resources.FailedUpdateVisaInfoState);
                    return(count);
                }
                ++count;
                LoadDataToDataGridView(_curPage);
            }
            else if (inputMode == Inputmode.Batch)
            {
                string outState = string.Empty;

                for (int i = 0; i != lines.Length; ++i)
                {
                    if (lines[i].Equals(OutStateString.Type02In))
                    {
                        outState = OutState.Type02In;
                    }
                    else if (lines[i].Equals(OutStateString.Type03NormalOut))
                    {
                        outState = OutState.Type03NormalOut;
                    }
                    else if (lines[i].Equals(OutStateString.Type04AbnormalOut))
                    {
                        outState = OutState.TYPE04AbnormalOut;
                    }
                    else
                    {
                        if (outState.Length == 0)
                        {
                            MessageBoxEx.Show(Resources.OutStateLengthEqualZero);
                            return(count);
                        }
                        VisaInfo model = GetModelByLine(lines[i]);
                        if (model == null)
                        {
                            MessageBoxEx.Show(Resources.FindModelFailedPleaseCheckInfoCorrect);
                            return(count);
                        }

                        UpdateModelState(model, outState);

                        if (!bll.Update(model))
                        {
                            MessageBoxEx.Show(Resources.FailedUpdateVisaInfoState);
                            return(count);
                        }
                        ++count;
                        if (updateSingle)
                        {
                            LoadDataToDataGridView(_curPage);
                        }
                    }
                }
            }
            if (!updateSingle)
            {
                LoadDataToDataGridView(_curPage);
            }
            return(count);
        }
Exemplo n.º 2
0
 private void rbtnBatch_CheckedChanged(object sender, EventArgs e)
 {
     _inputMode = Inputmode.Batch;
     btnParseBatchInput.Enabled = true;
     panelOutState.Enabled      = false;
 }