示例#1
0
        private void btnAmend_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lvPureves.SelectedItems.Count == 0)
                {
                    throw new MessageException("请选择要修改的项目!");
                }
                checkText();
                PurveyInfoData pid = getPInfo();
                pid.ID = ((PurveyInfoData)this.lvPureves.SelectedItems[0].Tag).ID;
                PInfoCortrol.updPurveyInfo(pid);

                ListViewItem lvi = new ListViewItem(pid.Name);
                lvi.Tag = pid;
                ListViewItem.ListViewSubItem lvs = new ListViewItem.ListViewSubItem();
                PurveyTypeData ptd = PTypeCortrol.getPTypeOfID(pid.PTypeID);
                lvs.Text = ptd.TypeName;
                lvs.Tag  = ptd;
                lvi.SubItems.Add(lvs);
                lvi.SubItems.Add(pid.LinkMan);
                lvi.SubItems.Add(pid.Tel);
                lvi.SubItems.Add(pid.Fox);
                lvi.SubItems.Add(pid.Email);
                lvi.SubItems.Add(pid.Days.ToString());
                lvi.SubItems.Add(pid.Address);

                this.lvPureves.Items[this.lvPureves.SelectedIndices[0]] = lvi;
                clear();
            }
            catch (MessageException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 向ListView里插入一条记录
        /// </summary>
        /// <param name="pid"></param>
        private void addPurevey(PurveyInfoData pid)
        {
            try
            {
                ListViewItem lvi = new ListViewItem(pid.Name);
                lvi.Tag = pid;
                ListViewItem.ListViewSubItem lvs = new ListViewItem.ListViewSubItem();
                PurveyTypeData ptd = PTypeCortrol.getPTypeOfID(pid.PTypeID);
                lvs.Text = ptd.TypeName;
                lvs.Tag  = ptd;
                lvi.SubItems.Add(lvs);
                lvi.SubItems.Add(pid.Days.ToString());
                lvi.SubItems.Add(pid.LinkMan);
                lvi.SubItems.Add(pid.Tel);
                lvi.SubItems.Add(pid.Fox);
                lvi.SubItems.Add(pid.Email);

                lvi.SubItems.Add(pid.Address);
                this.lvPureves.Items.Add(lvi);
            }
            catch (MessageException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 根据供应商获取订单头
        /// </summary>
        /// <param name="state">定单状态 0 未审批 1 审批 2 作废</param>
        /// <returns></returns>
        public static List <StockData> getStocks(PurveyInfoData pid)
        {
            string str = string.Empty;

            str = "PInfoID = " + pid.ID.ToString();
            return(st.selStock(str));
        }
示例#4
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.lvS.SelectedItems.Count == 0)
         {
             throw new MessageException("请选择要发送邮件的项目!");
         }
         StockData sd = (StockData)this.lvS.SelectedItems[0].Tag;
         if (sd.Down == false || sd.Blank == true)
         {
             throw new MessageException("只能打印审批过的订单!");
         }
         PurveyInfoData pid = PInfoCortrol.getPInfoOfID(sd.PInfoID);
         Other.SendMail(Set.set.SmtpUser, pid.Email, Set.set.ChaoName + "采购单",
                        "邮件正文", Set.set.SmtpServer, 21, Set.set.SmtpUser, Set.set.SmtpPwd);
     }
     catch (MessageException ex)
     {
         if (ex.Message != "")
         {
             MessageBox.Show(ex.Message);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#5
0
        private void addPInfo_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lvMInfo.SelectedItems.Count == 0)
                    return;

                frmSelectPInfo fspi = new frmSelectPInfo();
                PurveyInfoData pid = (PurveyInfoData)fspi.ShowSelect();
                foreach (ListViewItem lvi in this.lvPurvey.Items)
                {
                    if ((PurveyInfoData)lvi.Tag == pid)
                    {
                        lvi.Selected = true;
                        return;
                    }
                }
                frmInput fi = new frmInput("请输入供应价格");
                string str = fi.ShowInput();
                double price = Convert.ToDouble(str);
                PurveyData pd = new PurveyData();
                pd.PInfoID = pid.ID;
                pd.MInfoID = ((MerchandiseInfoData)this.lvMInfo.SelectedItems[0].Tag).ID;
                pd.Price = price;
                int i = PurveyCortrol.addPurevey(pd);
                pd.ID = i;
                addPurevey(pid, pd);
            }
            catch (MessageException ex)
            {
                if (ex.Message != "")
                    MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 增加供应商,且返回新增加记录的ID
        /// </summary>
        /// <param name="pid"></param>
        /// <returns>新增加的ID</returns>
        public static int addPurveyInfo(PurveyInfoData pid)
        {
            int i = pi.insertPurvey(pid);

            pid.ID = i;
            ls.Add(pid);
            return(i);
        }
示例#7
0
        /// <summary>
        /// 删除供应商信息
        /// </summary>
        /// <param name="purvey">供应商信息类</param>
        /// <returns></returns>
        public int delPurvey(PurveyInfoData purveyInfo)
        {
            SqlConnection conn = new SqlConnection(connStr);

            conn.Open();
            SqlCommand cmd = new SqlCommand("delete from purveyInfo where id = @id", conn);

            cmd.Parameters.AddWithValue("@id", purveyInfo.ID);
            int i = cmd.ExecuteNonQuery();

            conn.Close();
            return(i);
        }
        /// <summary>
        /// 删除供应商信息
        /// </summary>
        /// <param name="ptd">欲删除的类</param>
        public static void delPurveyInfo(PurveyInfoData pid)
        {
            pi.delPurvey(pid);
            int i;

            for (i = 0; i < ls.Count; i++)
            {
                if (pid.ID == ls[i].ID)
                {
                    ls.RemoveAt(i);
                    break;
                }
            }
        }
示例#9
0
        /// <summary>
        /// 根据用户的输入组成新类
        /// </summary>
        /// <returns></returns>
        private PurveyInfoData getPInfo()
        {
            PurveyInfoData pid = new PurveyInfoData();

            pid.Name    = this.txtName.Text;
            pid.PTypeID = ((PurveyTypeData)this.txtGenre.Tag).ID;
            pid.LinkMan = this.txtLinkMain.Text;
            pid.Tel     = this.txtTel.Text;
            pid.Fox     = this.txtFox.Text;
            pid.Address = this.txtAddress.Text;
            pid.Email   = this.txtMail.Text;
            pid.Days    = Convert.ToInt32(this.txtDays.Text);
            return(pid);
        }
        public Object ShowSelect(PurveyInfoData p)
        {
            this.pid = p;
            this.ShowDialog();
            if (this.lvMType.SelectedItems.Count == 0)
            {
                throw new MessageException("");
            }
            if (ok == false)
            {
                throw new MessageException("");
            }

            return(this.lvMType.SelectedItems[0].Tag);
        }
示例#11
0
        /// <summary>
        /// 修改供应商信息
        /// </summary>
        /// <param name="mtd">欲修改的类</param>
        /// <returns>返回所处集合的ID,对应ListView的项目位置</returns>
        public static int updPurveyInfo(PurveyInfoData pid)
        {
            pi.updatePurvey(pid);
            int i;

            for (i = 0; i < ls.Count; i++)
            {
                if (pid.ID == ls[i].ID)
                {
                    ls[i] = pid;
                    break;
                }
            }
            return(i);
        }
示例#12
0
 private void buttobtnAccessionn2_Click(object sender, EventArgs e)
 {
     try
     {
         checkText();
         PurveyInfoData pid = getPInfo();
         PInfoCortrol.addPurveyInfo(pid);
         addPurevey(pid);
         clear();
     }
     catch (MessageException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public StockInfoData showSelect(PurveyInfoData p)
        {
            this.pid = p;
            this.ShowDialog();
            if (ok == false)
            {
                throw new MessageException("");
            }

            StockInfoData sid = new StockInfoData();

            sid.MID      = ((MerchandiseInfoData)this.txtM.Tag).ID;
            sid.Quantity = Convert.ToInt32(this.txtQuantity.Text);
            sid.Price    = Convert.ToDouble(this.txtPrice.Text);
            return(sid);
        }
示例#14
0
 private void lvPureves_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.lvPureves.SelectedItems.Count > 0)
     {
         ListViewItem   lvi = this.lvPureves.SelectedItems[0];
         PurveyInfoData pid = (PurveyInfoData)lvi.Tag;
         this.txtName.Text     = pid.Name;
         this.txtGenre.Tag     = lvi.SubItems[1].Tag;
         this.txtGenre.Text    = lvi.SubItems[1].Text;
         this.txtLinkMain.Text = pid.LinkMan;
         this.txtTel.Text      = pid.Tel;
         this.txtFox.Text      = pid.Fox;
         this.txtAddress.Text  = pid.Address;
         this.txtMail.Text     = pid.Email;
         this.txtDays.Text     = pid.Days.ToString();
     }
 }
示例#15
0
 public void refurbish()
 {
     this.lvHint.Items.Clear();
     foreach (PurveyData pd in PurveyCortrol.ls)
     {
         MerchandiseInfoData mid = MInfoCortrol.getMInfoOfID(pd.MInfoID);
         PurveyInfoData      pid = PInfoCortrol.getPInfoOfID(pd.PInfoID);
         if (mid.Quantity * pid.Days > mid.Storage)
         {
             ListViewItem lvi = new ListViewItem(mid.Name);
             lvi.Tag = pd;
             lvi.SubItems.Add(mid.Storage.ToString());
             lvi.SubItems.Add(mid.Quantity.ToString());
             lvi.SubItems.Add(pid.Name);
             lvi.SubItems.Add(pid.Days.ToString());
             int i = -((mid.Storage - (mid.Quantity * pid.Days)) / mid.Quantity);
             lvi.SubItems.Add(i.ToString());
             this.lvHint.Items.Add(lvi);
         }
     }
 }
示例#16
0
 private void btnPInfoID_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.lvSInfo.Items.Count > 0)
         {
             throw new MessageException("已经添加了商品,请先清除商品或点重置按钮!");
         }
         frmSelectPInfo fspi = new frmSelectPInfo();
         PurveyInfoData pid  = (PurveyInfoData)fspi.ShowSelect();
         this.txtPInfo.Text = pid.Name;
         this.txtPInfo.Tag  = pid;
     }
     catch (MessageException ex)
     {
         if (ex.Message != "")
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
示例#17
0
        /// <summary>
        /// 修改供应商信息
        /// </summary>
        /// <param name="purvey">供应商信息类</param>
        /// <returns></returns>
        public int updatePurvey(PurveyInfoData purveyInfo)
        {
            SqlConnection conn = new SqlConnection(connStr);

            conn.Open();
            SqlCommand cmd = new SqlCommand("update purveyInfo set name = @name,PTypeID = @PTypeID,LinkMan = @LinkMan,Tel= @Tel,Fox = @Fox,Address = @Address,Email=@Email,Days=@Days where id = @id", conn);

            cmd.Parameters.AddWithValue("@id", purveyInfo.ID);
            cmd.Parameters.AddWithValue("@name", purveyInfo.Name);
            cmd.Parameters.AddWithValue("@PTypeID", purveyInfo.PTypeID);
            cmd.Parameters.AddWithValue("@LinkMan", purveyInfo.LinkMan);
            cmd.Parameters.AddWithValue("@Tel", purveyInfo.Tel);
            cmd.Parameters.AddWithValue("@Fox", purveyInfo.Fox);
            cmd.Parameters.AddWithValue("@Address", purveyInfo.Address);
            cmd.Parameters.AddWithValue("@Email", purveyInfo.Email);
            cmd.Parameters.AddWithValue("@Days", purveyInfo.Days);
            int i = cmd.ExecuteNonQuery();

            conn.Close();
            return(i);
        }
        public StockInfoData showSelect(PurveyInfoData p, MerchandiseInfoData mid, string quantity, string price)
        {
            this.pid              = p;
            this.btnYes.Text      = "    修改";
            this.txtM.Text        = mid.Name;
            this.txtM.Tag         = mid;
            this.txtPrice.Text    = price;
            this.txtQuantity.Text = quantity;

            this.ShowDialog();
            if (ok == false)
            {
                throw new MessageException("");
            }

            StockInfoData sid = new StockInfoData();

            sid.MID      = ((MerchandiseInfoData)this.txtM.Tag).ID;
            sid.Quantity = Convert.ToInt32(this.txtQuantity.Text);
            sid.Price    = Convert.ToDouble(this.txtPrice.Text);
            return(sid);
        }
示例#19
0
        /// <summary>
        /// 插入供应商信息
        /// </summary>
        /// <param name="purvey">供应商信息类</param>
        /// <returns></returns>
        public int insertPurvey(PurveyInfoData purveyInfo)
        {
            SqlConnection conn = new SqlConnection(connStr);

            conn.Open();
            SqlCommand cmd = new SqlCommand("insert into purveyInfo values(@name,@PTypeID,@LinkMan,@Tel,@Fox,@Address,@Email,@Days)", conn);

            cmd.Parameters.AddWithValue("@name", purveyInfo.Name);
            cmd.Parameters.AddWithValue("@PTypeID", purveyInfo.PTypeID);
            cmd.Parameters.AddWithValue("@LinkMan", purveyInfo.LinkMan);
            cmd.Parameters.AddWithValue("@Tel", purveyInfo.Tel);
            cmd.Parameters.AddWithValue("@Fox", purveyInfo.Fox);
            cmd.Parameters.AddWithValue("@Address", purveyInfo.Address);
            cmd.Parameters.AddWithValue("@Email", purveyInfo.Email);
            cmd.Parameters.AddWithValue("@Days", purveyInfo.Days);
            cmd.ExecuteNonQuery();
            cmd.CommandText = "select @@IDENTITY";
            int i = Convert.ToInt32(cmd.ExecuteScalar());

            conn.Close();
            return(i);
        }
示例#20
0
        /// <summary>
        /// 查询供应商信息
        /// </summary>
        /// <param name="purvey">供应商信息类</param>
        /// <returns>返回供应商信息集合</returns>
        public List <PurveyInfoData> selPurvey()
        {
            List <PurveyInfoData> list = new List <PurveyInfoData>();
            SqlConnection         conn = new SqlConnection(connStr);
            SqlDataAdapter        sda  = new SqlDataAdapter("select * from purveyInfo", conn);
            DataSet ds = new DataSet();

            sda.Fill(ds);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                PurveyInfoData pur = new PurveyInfoData();
                pur.ID      = (int)dr[0];
                pur.Name    = dr[1].ToString();
                pur.PTypeID = (int)dr[2];
                pur.LinkMan = dr[3].ToString();
                pur.Tel     = dr[4].ToString();
                pur.Fox     = dr[5].ToString();
                pur.Address = dr[6].ToString();
                pur.Email   = dr[7].ToString();
                pur.Days    = (int)dr[8];
                list.Add(pur);
            }
            return(list);
        }