Exemple #1
0
        private string GetPumpClass(string s)
        {
            ExtractType et   = ImpExtractType.getInstance();
            string      type = et.ExtractTypeFromName(s);

            return(type);
        }
Exemple #2
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            if (tabControl1.SelectedTab == tabPage3)
            {
                return;
            }
            #region Tab1
            if (tabControl1.SelectedTab == tabPage1)
            {
                string s = listBox1.Items[0].ToString();
                s = Path.GetFileName(s);
                string[] HorzArrays = s.Split(new char[] { '-' });
                if (HorzArrays.Length >= 3)
                {
                    textBox1.Text = HorzArrays[0] + "-" + HorzArrays[1];
                }
                else
                {
                    if (HorzArrays.Length == 1)
                    {
                        textBox1.Text = HorzArrays[0];
                    }
                    else
                    {
                        if (HorzArrays.Length == 2)
                        {
                            textBox1.Text = HorzArrays[0] + "-" + HorzArrays[1].Substring(0, 3);
                        }
                    }
                }

                ExtractType et   = ImpExtractType.getInstance();
                string      type = et.ExtractTypeFromName(textBox1.Text);
                textBox2.Text = type;

                string typeX = Util.Comm.GetPumpClass(textBox2.Text);

                if (typeX.Length > 1)
                {
                    cmbPump.Text        = typeX;
                    pictureBox1.Visible = true;
                    bFindType           = true;
                }

                textBox3.Text           = FindUser();
                tabControl1.SelectedTab = tabPage2;

                return;
            }
            #endregion

            #region Tab2
            if (tabControl1.SelectedTab == tabPage2)
            {
                tabControl1.SelectedTab = tabPage3;
                if (checkBox1.Checked && !bFindType)
                {
                    Util.Comm.SavePumpClass(textBox2.Text, cmbPump.Text);
                }
                string str_Path = CombinePath();
                string strFile;

                if (!Directory.Exists(str_Path))
                {
                    Directory.CreateDirectory(str_Path);
                }

                Cursor curCursor = this.Cursor;
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    int iCount = listBox1.Items.Count;
                    progressBar1.Minimum = 0;
                    progressBar1.Maximum = iCount;
                    label1.Text          = "正在入库....";
                    foreach (object s in listBox1.Items)
                    {
                        progressBar1.Value++;
                        strFile = Path.GetFileName(s.ToString());
                        File.Copy(s.ToString(), str_Path + @"\" + strFile, true);

                        Util.Comm.SaveInLibRecord(textBox3.Text,
                                                  cmbPump.Text,
                                                  textBox1.Text,
                                                  strFile,
                                                  cmbFile.Text);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    this.Cursor        = curCursor;
                    label1.Text        = "进行";
                    progressBar1.Value = 0;
                }


                if (cmbFile.Text == @"产品\模型图")
                {
                    string fileName;
                    string Moxing = @"\\server\模型图\";
                    foreach (object s in listBox1.Items)
                    {
                        fileName = s.ToString();
                        File.Copy(fileName, Moxing + Path.GetFileName(fileName), true);
                    }
                }

                MessageBox.Show(this, "入库成功!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            #endregion
        }