private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            txtGoodsName.Text  = dataGridView1.CurrentRow.Cells["OldGoodsName"].Value.ToString();
            txtGoodsSpec.Text  = dataGridView1.CurrentRow.Cells["OldSpec"].Value.ToString();
            txtOldCode.Text    = dataGridView1.CurrentRow.Cells["OldGoodsCode"].Value.ToString();
            txtOldCode.Tag     = m_basicGoodsServer.GetGoodsIDByGoodsCode(txtOldCode.Text, txtGoodsName.Text, txtGoodsSpec.Text).ToString();
            textBox1.Text      = dataGridView1.CurrentRow.Cells["NewSpec"].Value.ToString();
            textBox2.Text      = dataGridView1.CurrentRow.Cells["NewGoodsName"].Value.ToString();
            txtNewCode.Text    = dataGridView1.CurrentRow.Cells["NewGoodsCode"].Value.ToString();
            txtNewCode.Tag     = m_basicGoodsServer.GetGoodsIDByGoodsCode(txtNewCode.Text, textBox2.Text, textBox1.Text).ToString();
            txtOldCvtID.Text   = dataGridView1.CurrentRow.Cells["OldCvtID"].Value.ToString();
            txtNewCvtID.Text   = dataGridView1.CurrentRow.Cells["NewCvtID"].Value.ToString();
            txtNewGoodsID.Text = dataGridView1.CurrentRow.Cells["NewGoods"].Value.ToString();
            txtOldGoodsID.Text = dataGridView1.CurrentRow.Cells["OldGoods"].Value.ToString();

            if (dataGridView1.CurrentRow.Cells["Count"].Value.ToString().Trim() == "" ||
                dataGridView1.CurrentRow.Cells["Count"].Value.ToString() == null)
            {
                txtCount.Value = 0;
            }
            else
            {
                txtCount.Value = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["Count"].Value.ToString());
            }

            txtUnit.Text = dataGridView1.CurrentRow.Cells["Unit"].Value.ToString();

            m_intOldGoodsID = m_basicGoodsServer.GetGoodsID(txtOldCode.Text, txtGoodsName.Text, txtOldCode.Text);
        }
Beispiel #2
0
        private void 导入toolStripButton_Click(object sender, EventArgs e)
        {
            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

            if (dtTemp == null)
            {
                //MessageDialog.ShowPromptMessage(m_error);
                return;
            }

            if (!CheckTable(dtTemp))
            {
                return;
            }

            DataTable dtClone = dtTemp.Clone();

            foreach (DataRow dr in dtTemp.Rows)
            {
                YX_LowestMarketPrice lowest = new YX_LowestMarketPrice();

                int GoodsID = m_basicGoodsServer.GetGoodsIDByGoodsCode(dr["容大代码"].ToString(),
                                                                       dr["零件名称"].ToString(), dr["规格"].ToString());

                if (GoodsID != 0 && GoodsID != 7126)
                {
                    lowest.GoodsID = GoodsID;
                }
                else
                {
                    AddErrorInfo(ref dtClone, dr);
                    continue;
                }

                string clientCode = m_clientServer.GetClientCode(dr["客户名称"].ToString());

                if (clientCode != "")
                {
                    lowest.ClientID = clientCode;
                }
                else
                {
                    AddErrorInfo(ref dtClone, dr);
                    continue;
                }

                int?communicateID = m_LowestPriceServer.GetCommunicateID(lowest.ClientID, dr["主机厂图号型号"].ToString(),
                                                                         dr["主机厂物品名称"].ToString(), lowest.GoodsID, out m_error);

                if (communicateID != null)
                {
                    lowest.CommunicateID = communicateID;
                }
                else
                {
                    AddErrorInfo(ref dtClone, dr);
                    continue;
                }

                lowest.Date          = ServerTime.Time;
                lowest.Price         = Convert.ToDecimal(dr["配件含税单价(元)"].ToString());
                lowest.TerminalPrice = Convert.ToDecimal(dr["配件终端最低价(元)"].ToString());
                lowest.Rater         = BasicInfo.LoginID;
                lowest.Remark        = dr["备注"].ToString();

                if (!m_LowestPriceServer.InsertAndUpdateData(lowest, out m_error))
                {
                    AddErrorInfo(ref dtClone, dr);
                    continue;
                }
            }

            if (dtClone.Rows.Count > 0)
            {
                FormShowYXLowestPriceError form = new FormShowYXLowestPriceError(dtTemp, null);
                form.ShowDialog();
            }
            else
            {
                MessageDialog.ShowPromptMessage("导入成功");
            }

            #region 逻辑代码修改 Modify by cjb on 2015.11.18
            //bool flag = false;
            ////string GoodsName = "";

            //for (int i = 0; i < dtTemp.Rows.Count; i++)
            //{
            //    YX_LowestMarketPrice lowest = new YX_LowestMarketPrice();

            //    lowest.Date = ServerTime.Time;

            //    int GoodsID = m_basicGoodsServer.GetGoodsIDByGoodsCode(
            //        dtTemp.Rows[i]["容大代码"].ToString(), dtTemp.Rows[i]["零件名称"].ToString(), dtTemp.Rows[i]["规格"].ToString());

            //    if (GoodsID != 0 && GoodsID != 7126)
            //    {
            //        lowest.GoodsID = GoodsID;
            //    }
            //    else if (GoodsID == 7126)
            //    {
            //        dtTemp.Rows.RemoveAt(i);
            //        i--;
            //        continue;
            //    }
            //    else
            //    {
            //        //GoodsName += "容大代码为:" + dtTemp.Rows[i]["容大代码"].ToString() + ";零件名称:" +
            //        //    dtTemp.Rows[i]["零件名称"].ToString() + "的零件有误,系统没有该零件;\r\n";
            //        flag = true;

            //        continue;
            //    }

            //    lowest.Price = Convert.ToDecimal(dtTemp.Rows[i]["配件含税单价(元)"].ToString());
            //    lowest.TerminalPrice = Convert.ToDecimal(dtTemp.Rows[i]["配件终端最低价(元)"].ToString());
            //    lowest.Rater = BasicInfo.LoginID;
            //    lowest.Remark = dtTemp.Rows[i]["备注"].ToString();
            //    string clientCode = m_clientServer.GetClientCode(dtTemp.Rows[i]["客户名称"].ToString());

            //    if (clientCode != "")
            //    {
            //        lowest.ClientID = clientCode;

            //        string communicateID = m_LowestPriceServer.GetCommunicateID(clientCode, dtTemp.Rows[i]["主机厂图号型号"].ToString(),
            //            dtTemp.Rows[i]["主机厂物品名称"].ToString(), GoodsID, out m_error);

            //        if (communicateID != "")
            //        {
            //            lowest.CommunicateID = communicateID;
            //        }
            //        else
            //        {
            //            flag = true;
            //            continue;
            //        }
            //    }
            //    else
            //    {
            //        flag = true;
            //        continue;
            //    }

            //    if (!m_LowestPriceServer.InsertAndUpdateData(lowest, out m_error))
            //    {
            //        flag = true;
            //    }
            //    else
            //    {
            //        dtTemp.Rows.RemoveAt(i);
            //        i--;
            //    }
            //}

            //if (flag)
            //{
            //    FormShowYXLowestPriceError form = new FormShowYXLowestPriceError(dtTemp,null);
            //    form.ShowDialog();
            //}
            //else
            //{
            //    MessageDialog.ShowPromptMessage("导入成功");
            //}

            #endregion
        }