Пример #1
0
        private void btnInput_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageDialog.ShowEnquiryMessage("请确认所导入的EXCEL文件第一列为所需要导入的编号信息且列名为【旧箱箱号】,第二列为所需要导入的编号信息且列名为【新箱箱号】") == DialogResult.No)
                {
                    return;
                }

                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null)
                {
                    return;
                }
                else
                {
                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        if (dr[0].ToString().Trim().Length != 0 && dr[1].ToString().Trim().Length != 0)
                        {
                            txtOldCVTNumber.Text = dr[0].ToString();
                            txtNewCVTNumber.Text = dr[1].ToString();
                            btnAdd_Click(sender, e);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return;
            }
        }
        private void 导入EXCELToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (dtTemp.Rows.Count == 0 ||
                dtTemp.Columns[0].ColumnName != "物品ID" ||
                dtTemp.Columns[1].ColumnName != "图号型号" ||
                dtTemp.Columns[2].ColumnName != "物品名称" ||
                dtTemp.Columns[3].ColumnName != "规格" ||
                dtTemp.Columns[4].ColumnName != "物品实际平均价")
            {
                MessageDialog.ShowPromptMessage(string.Format("{0} 中没有包含所需的信息,无法导入!",
                                                              openFileDialog1.FileName));
            }
            else
            {
                m_blFlag = true;
                dataGridView1.DataSource = dtTemp;
                MessageDialog.ShowPromptMessage("导入成功请点击【物品平均价校对】进行校对");
            }
        }
Пример #3
0
        private void btnInExcel_Click(object sender, EventArgs e)
        {
            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (CheckTable(dtTemp))
            {
                if (!m_serverCVTCustomer.BatchInsertCVTCustomerInformation(dtTemp, out m_strError))
                {
                    MessageDialog.ShowPromptMessage(m_strError);
                    return;
                }
                else
                {
                    string strMessage = "";

                    if (m_strError != null)
                    {
                        strMessage = "\n以下车架号的记录日期格式不正确"
                                     + m_strError + "\n系统已默认为【2099-12-31】,请自行修改";
                    }

                    MessageDialog.ShowPromptMessage("导入成功" + strMessage);
                }
            }

            ClearDate();
            RefreshDataGirdView(m_serverCVTCustomer.GetCVTCustomerInformation());
        }
        private void 导入toolStripButton_Click(object sender, EventArgs e)
        {
            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (CheckTable(dtTemp))
            {
                if (!m_personnerServer.InsertPersonnelArchiveInfo(dtTemp, out error))
                {
                    MessageDialog.ShowPromptMessage(error);
                    return;
                }
                else
                {
                    MessageDialog.ShowPromptMessage("导入成功!");
                }
            }

            RefreshControl();
        }
Пример #5
0
        private void btnInExcel_Click(object sender, EventArgs e)
        {
            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

            if (dtTemp == null)
            {
                MessageDialog.ShowPromptMessage("文件无效,转换失败");
                return;
            }

            if (!dtTemp.Columns.Contains("图号型号"))
            {
                MessageDialog.ShowPromptMessage("无【图号型号】列");
                return;
            }

            if (!dtTemp.Columns.Contains("物品名称"))
            {
                MessageDialog.ShowPromptMessage("无【物品名称】列");
                return;
            }

            if (!dtTemp.Columns.Contains("规格"))
            {
                MessageDialog.ShowPromptMessage("无【规格】列");
                return;
            }

            if (!dtTemp.Columns.Contains("基数"))
            {
                MessageDialog.ShowPromptMessage("无【基数】列");
                return;
            }

            if (!dtTemp.Columns.Contains("总成型号"))
            {
                MessageDialog.ShowPromptMessage("无【总成型号】列");
                return;
            }

            if (!dtTemp.Columns.Contains("安全库存"))
            {
                MessageDialog.ShowPromptMessage("无【安全库存】列");
                return;
            }

            try
            {
                m_serverCBOM.BatchInsertCGBom(dtTemp);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return;
            }

            RefreshData();
            MessageDialog.ShowPromptMessage("导入完成");
        }
Пример #6
0
        private void btn_QuestionBank_Input_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null)
                {
                    return;
                }

                if (!dtTemp.Columns.Contains("考题ID"))
                {
                    MessageDialog.ShowPromptMessage("文件中无【考题ID】列");
                    return;
                }

                if (!dtTemp.Columns.Contains("考题类型"))
                {
                    MessageDialog.ShowPromptMessage("文件中无【考题类型】列");
                    return;
                }

                if (!dtTemp.Columns.Contains("考题内容"))
                {
                    MessageDialog.ShowPromptMessage("文件中无【考题内容】列");
                    return;
                }

                if (!dtTemp.Columns.Contains("选项"))
                {
                    MessageDialog.ShowPromptMessage("文件中无【选项】列");
                    return;
                }

                if (!dtTemp.Columns.Contains("选项内容"))
                {
                    MessageDialog.ShowPromptMessage("文件中无【选项内容】列");
                    return;
                }

                if (!dtTemp.Columns.Contains("答案"))
                {
                    MessageDialog.ShowPromptMessage("文件中无【答案】列");
                    return;
                }

                _ServiceBasicInfo.InputQuestionsBank(_CourseInfo.ID, dtTemp);
                MessageDialog.ShowPromptMessage("导入成功");
                dgv_QuestionBank.DataSource =
                    new BindingCollection <View_HR_Train_QuestionBank>(_ServiceBasicInfo.GetListQuestionBank(_CourseInfo.ID));
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
        private void btnExcel_Click(object sender, EventArgs e)
        {
            if (txtClient.Text == "")
            {
                MessageDialog.ShowPromptMessage("请选择客户后再进行此操作!");
                return;
            }

            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (CheckTable(dtTemp))
            {
                dtTemp.Columns.Add("物品ID");
                dtTemp.Columns.Add("客户零件代码");
                dtTemp.Columns.Add("客户零件名称");
                DataRow dr = dtTemp.NewRow();

                for (int i = 0; i < dtTemp.Rows.Count; i++)
                {
                    DataRow row = dtTemp.Rows[i];

                    row["物品ID"] = UniversalFunction.GetGoodsID(row["图号型号"].ToString(), row["物品名称"].ToString(), row["规格"].ToString());

                    if (Convert.ToInt32(row["物品ID"]) == 0)
                    {
                        MessageDialog.ShowPromptMessage("第" + i + "行零件有误,请确认!");
                        return;
                    }

                    DataTable dt = m_salesOrderServer.GetCommunicate(txtClient.Tag.ToString(),
                                                                     Convert.ToInt32(row["物品ID"]));

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        row["客户零件代码"] = m_salesOrderServer.GetCommunicate(txtClient.Tag.ToString(),
                                                                          Convert.ToInt32(row["物品ID"])).Rows[0]["CommunicateGoodsCode"];
                        row["客户零件名称"] = m_salesOrderServer.GetCommunicate(txtClient.Tag.ToString(),
                                                                          Convert.ToInt32(row["物品ID"])).Rows[0]["CommunicateGoodsName"];
                    }
                    else
                    {
                        row["客户零件代码"] = "";
                        row["客户零件名称"] = "";
                    }
                }

                dgvPartList.DataSource = dtTemp;
            }
        }
Пример #8
0
        private void btnIn_Click(object sender, EventArgs e)
        {
            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (dtTemp.Rows.Count == 0 ||
                dtTemp.Columns[0].ColumnName != "物品ID" ||
                dtTemp.Columns[1].ColumnName != "图号型号" ||
                dtTemp.Columns[2].ColumnName != "物品名称" ||
                dtTemp.Columns[3].ColumnName != "规格" ||
                dtTemp.Columns[4].ColumnName != "单位" ||
                dtTemp.Columns[5].ColumnName != "单价")
            {
                MessageDialog.ShowPromptMessage(string.Format("{0} 中没有包含所需的信息,无法导入!",
                                                              openFileDialog1.FileName));
            }
            else
            {
                for (int i = 0; i < dtTemp.Rows.Count; i++)
                {
                    View_F_GoodsPlanCost tempGoodsLnq = UniversalFunction.GetGoodsInfo(dtTemp.Rows[i]["图号型号"].ToString(),
                                                                                       dtTemp.Rows[i]["物品名称"].ToString(), dtTemp.Rows[i]["规格"].ToString());

                    if (tempGoodsLnq != null)
                    {
                        dtTemp.Rows[i]["物品ID"] = tempGoodsLnq.序号;
                        dtTemp.Rows[i]["单位"]   = tempGoodsLnq.单位;
                    }
                    else
                    {
                        dtTemp.Rows.RemoveAt(i);
                    }
                }

                if (!m_serverThreePacketsOfTheRepairBill.UpdateAllGoodsUnitPrice(
                        MessageBox.Show("是否删除原有记录", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes? true : false,
                        dtTemp, out m_strErr))
                {
                    MessageDialog.ShowPromptMessage(m_strErr);
                }

                dataGridView1.DataSource = m_serverThreePacketsOfTheRepairBill.GetGoodsUnitPriceInfo();

                userControlDataLocalizer1.Init(dataGridView1, this.Name,
                                               UniversalFunction.SelectHideFields(this.Name, dataGridView1.Name, BasicInfo.LoginID));

                MessageDialog.ShowPromptMessage("导入成功");
            }
        }
        private void btnInputExcel_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null)
                {
                    return;
                }

                if (!dtTemp.Columns.Contains("图号型号"))
                {
                    MessageDialog.ShowPromptMessage("文件无【图号型号】列名");
                    return;
                }

                if (!dtTemp.Columns.Contains("物品名称"))
                {
                    MessageDialog.ShowPromptMessage("文件无【物品名称】列名");
                    return;
                }

                if (!dtTemp.Columns.Contains("规格"))
                {
                    MessageDialog.ShowPromptMessage("文件无【规格】列名");
                    return;
                }

                if (!dtTemp.Columns.Contains("批次号"))
                {
                    MessageDialog.ShowPromptMessage("文件无【批次号】列名");
                    return;
                }

                if (!dtTemp.Columns.Contains("数量"))
                {
                    MessageDialog.ShowPromptMessage("文件无【数量】列名");
                    return;
                }

                m_goodsServer.InsertInfoExcel(m_billNo, dtTemp);
                MessageDialog.ShowPromptMessage("导入成功");
                m_queryGoodsInfo = m_goodsServer.GetGoods(m_billNo);
                RefreshDataGridView(m_queryGoodsInfo);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return;
            }
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1.OpenFile());

            if (dtTemp == null)
            {
                MessageDialog.ShowPromptMessage(m_err);
                return;
            }
            else
            {
                if (!dtTemp.Columns.Contains("零件编码") ||
                    !dtTemp.Columns.Contains("零件名称") ||
                    !dtTemp.Columns.Contains("规格") ||
                    !dtTemp.Columns.Contains("基数"))
                {
                    MessageDialog.ShowPromptMessage("表中的列未包含【零件编码】,【零件名称】,【规格】,【基数】,请重新核对");
                }

                DataTable sourceTable = ((DataTable)Dgv_Main.DataSource).Clone();

                foreach (DataRow dr in dtTemp.Rows)
                {
                    if (dr["零件编码"].ToString().Trim().Length > 0 ||
                        dr["零件名称"].ToString().Trim().Length > 0)
                    {
                        DataRow tempRow = sourceTable.NewRow();

                        tempRow["产品编码"] = tbsEditionName.Tag.ToString();
                        tempRow["父级编码"] = "";
                        tempRow["零件编码"] = dr["零件编码"];
                        tempRow["零件名称"] = dr["零件名称"];
                        tempRow["规格"]   = dr["规格"];
                        tempRow["基数"]   = dr["基数"];
                        tempRow["别名"]   = "";
                        tempRow["顺序位置"] = 0;

                        sourceTable.Rows.Add(tempRow);
                    }
                }

                Dgv_Main.DataSource = sourceTable;
            }
        }
Пример #11
0
        private void 导入toolStripButton_Click(object sender, EventArgs e)
        {
            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (!m_providerServer.InsertProvidersInfo(dtTemp, out m_error))
            {
                MessageDialog.ShowPromptMessage(m_error);
            }
        }
        private void btnInExcel_Click(object sender, EventArgs e)
        {
            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (dtTemp.Rows.Count == 0 ||
                !dtTemp.Columns.Contains("新箱号") ||
                !dtTemp.Columns.Contains("旧箱号") ||
                !dtTemp.Columns.Contains("新箱型号") ||
                !dtTemp.Columns.Contains("旧箱型号") ||
                !dtTemp.Columns.Contains("备注"))
            {
                MessageDialog.ShowPromptMessage(string.Format("{0} 中没有包含所需的信息,无法导入!",
                                                              openFileDialog1.FileName));
            }
            else
            {
                string strBatchNo = m_sell.GetMatchingBillID();

                for (int i = 0; i < dtTemp.Rows.Count; i++)
                {
                    m_lnqNewAndOld.BatchNo        = strBatchNo;
                    m_lnqNewAndOld.NewProductCode = dtTemp.Rows[i]["新箱号"].ToString();
                    m_lnqNewAndOld.OldProductCode = dtTemp.Rows[i]["旧箱号"].ToString();
                    m_lnqNewAndOld.NewEdition     = dtTemp.Rows[i]["新箱型号"].ToString();
                    m_lnqNewAndOld.OldEdition     = dtTemp.Rows[i]["旧箱型号"].ToString();
                    m_lnqNewAndOld.Remark         = dtTemp.Rows[i]["备注"].ToString();

                    if (m_sell.IsSameProductMatchingInfo(m_lnqNewAndOld))
                    {
                        if (!m_sell.AddMatchingInfo(m_lnqNewAndOld, out m_err))
                        {
                            MessageDialog.ShowPromptMessage(m_err);
                        }
                    }
                }

                MessageDialog.ShowPromptMessage("导入成功!");
            }

            dataGridView1.DataSource            = m_sell.GetProductCodeMatchingInfo();
            dataGridView1.Columns["序号"].Visible = false;
        }
        private void btn变更允许调休小时数_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dialog = new OpenFileDialog();
                DataTable      dt     = ExcelHelperP.RenderFromExcel(dialog);

                if (dt != null)
                {
                    List <HR_AttendanceSummary> lstSummary = new List <HR_AttendanceSummary>();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if ((dt.Rows[i]["工号"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dt.Rows[i]["工号"].ToString())) ||
                            (dt.Rows[i]["年份"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dt.Rows[i]["年份"].ToString())) ||
                            (dt.Rows[i]["月份"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dt.Rows[i]["月份"].ToString())) ||
                            (dt.Rows[i]["允许调休小时数"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dt.Rows[i]["允许调休小时数"].ToString())))
                        {
                            throw new Exception("第" + (i + 2).ToString() + "行记录存在【空数据】");
                        }

                        if (UniversalFunction.GetPersonnelInfo(dt.Rows[i]["工号"].ToString()) == null)
                        {
                            throw new Exception("【工号】:" + dt.Rows[i]["工号"].ToString() + ", 不存在");
                        }

                        HR_AttendanceSummary summary = new HR_AttendanceSummary();

                        summary.WorkID = dt.Rows[i]["工号"].ToString();
                        summary.Year   = Convert.ToInt32(dt.Rows[i]["年份"]);
                        summary.Month  = Convert.ToInt32(dt.Rows[i]["月份"]);
                        summary.AllowMobileVacationHours = Convert.ToDouble(dt.Rows[i]["允许调休小时数"]);

                        lstSummary.Add(summary);
                    }

                    m_attendanceServer.UpdateAllowMobileHours(lstSummary);

                    MessageDialog.ShowPromptMessage("修改【允许调休小时数】成功");
                }
            }
            catch (Exception exce)
            {
                MessageDialog.ShowErrorMessage(exce.Message);
            }
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (txtFileName.Text.Trim().Length > 0)
            {
                if (System.IO.File.Exists(txtFileName.Text))
                {
                    openFileDialog1.FileName = txtFileName.Text;
                }
                else
                {
                    MessageDialog.ShowPromptMessage("不存在的数据文件:" + txtFileName.Text);
                    return;
                }
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(openFileDialog1.FileName))
            {
                MessageDialog.ShowPromptMessage("请选择要导入的文件后再进行此操作!");
                return;
            }

            try
            {
                Data = ExcelHelperP.RenderFromExcel(openFileDialog1.OpenFile());

                if (Data != null || Data.Rows.Count == 0 ||
                    Data.Columns[0].ColumnName != "液力变矩器型号" || Data.Columns[4].ColumnName != "变矩器出厂编号")
                {
                    MessageDialog.ShowPromptMessage(string.Format("{0} 中没有包含所需的信息,无法导入!", openFileDialog1.FileName));
                    return;
                }

                Complete = true;

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exce)
            {
                MessageDialog.ShowErrorMessage(exce.Message);
            }
        }
        private void btnIn_Click(object sender, EventArgs e)
        {
            主机厂报表操作指示窗体 form = new 主机厂报表操作指示窗体();

            form.ShowDialog();

            if (!form.BlFlag)
            {
                return;
            }

            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (dtTemp.Rows.Count == 0 ||
                dtTemp.Columns[0].ColumnName != "图号型号" ||
                dtTemp.Columns[1].ColumnName != "物品名称" ||
                dtTemp.Columns[2].ColumnName != "协议单价" ||
                dtTemp.Columns[3].ColumnName != "实挂数量")
            {
                MessageDialog.ShowPromptMessage(string.Format("{0} 中没有包含所需的信息,无法导入!",
                                                              openFileDialog1.FileName));
            }
            else
            {
                if (!m_serverComReportBill.UpdateSignTheBill(form.StrCommunicate, dtTemp, out m_strErr))
                {
                    MessageDialog.ShowPromptMessage(m_strErr);
                }
                else
                {
                    MessageDialog.ShowPromptMessage("导入成功");
                }
            }
        }
Пример #16
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))
            {
                if (!m_postServer.AddDeptPost(dtTemp, out m_error))
                {
                    MessageDialog.ShowPromptMessage(m_error);
                    return;
                }
                else
                {
                    MessageDialog.ShowPromptMessage("导入成功!");
                }
            }
        }
Пример #17
0
        private void btnSupplementary_InProduct_Click(object sender, EventArgs e)
        {
            try
            {
                string yearMonth = "";

                择年月 frm = new  择年月();

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    yearMonth = frm._Str_YearMonth;
                }
                else
                {
                    return;
                }

                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null)
                {
                    return;
                }

                if (!dtTemp.Columns.Contains("图号型号"))
                {
                    throw new Exception("文件无【图号型号】列名");
                }

                if (!dtTemp.Columns.Contains("物品名称"))
                {
                    throw new Exception("文件无【物品名称】列名");
                }

                if (!dtTemp.Columns.Contains("规格"))
                {
                    throw new Exception("文件无【规格】列名");
                }

                if (!dtTemp.Columns.Contains("实盘数"))
                {
                    throw new Exception("文件无【实盘数】列名");
                }

                List <Bus_WorkShop_InProduct> lstInfo = new List <Bus_WorkShop_InProduct>();

                for (int i = 0; i < dtTemp.Rows.Count; i++)
                {
                    int goodsID = UniversalFunction.GetGoodsID(dtTemp.Rows[i]["图号型号"].ToString(),
                                                               dtTemp.Rows[i]["物品名称"].ToString(), dtTemp.Rows[i]["规格"].ToString());

                    if (goodsID == 0)
                    {
                        throw new Exception(string.Format("第【{0}】行,图号型号:{1},物品名称:{2},规格:{3},无法找到匹配的物品ID", i.ToString(),
                                                          dtTemp.Rows[i]["图号型号"].ToString(), dtTemp.Rows[i]["物品名称"].ToString(), dtTemp.Rows[i]["规格"].ToString()));
                    }

                    Bus_WorkShop_InProduct tempInfo = new Bus_WorkShop_InProduct();
                    tempInfo.F_Id      = Guid.NewGuid().ToString();
                    tempInfo.GoodsID   = goodsID;
                    tempInfo.YearMonth = yearMonth;

                    decimal goodsCount = 0;
                    Decimal.TryParse(dtTemp.Rows[i]["实盘数"] == null ? "" : dtTemp.Rows[i]["实盘数"].ToString(), out goodsCount);
                    tempInfo.NowBalanceCount = goodsCount;

                    lstInfo.Add(tempInfo);
                }

                _Service_InProcutReport.InputNowBalanceCount(lstInfo);
                MessageDialog.ShowPromptMessage("导入成功");
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return;
            }
        }
        private void btnLoadExcel_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog        openFileDialog1 = new OpenFileDialog();
                System.Data.DataTable dtTemp          = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null || dtTemp.Rows.Count == 0 || dtTemp.Columns.Count < 8 || dtTemp.Rows.Count != 39)
                {
                    MessageDialog.ShowPromptMessage("加载的EXCEL文件数据格式错误");
                    return;
                }

                string error       = null;
                string productCode = dtTemp.Rows[0][3].ToString();
                string cvtNumber   = dtTemp.Rows[0][6].ToString();

                if (!ServerModule.ServerModuleFactory.GetServerModule <IProductCodeServer>().VerifyProductCodesInfo(
                        productCode, cvtNumber, GlobalObject.CE_BarCodeType.内部钢印码, out error))
                {
                    MessageDialog.ShowErrorMessage(error);
                    return;
                }

                string 试验设备名称 = dtTemp.Rows[1][3].ToString();
                string 油品     = "出光1";
                string 试验结果   = dtTemp.Rows[37][5].ToString();

                IPersonnelArchiveServer personnelInfoServer = Service_Peripheral_HR.ServerModuleFactory.GetServerModule <IPersonnelArchiveServer>();

                string 装配员工号 = personnelInfoServer.GetPersonnelViewInfoByName(dtTemp.Rows[38][4].ToString());

                if (GlobalObject.GeneralFunction.IsNullOrEmpty(装配员工号))
                {
                    MessageDialog.ShowPromptMessage("文件中的装配员姓名在公司不唯一,无法获取到员工编号");
                    return;
                }

                string 线员工号 = personnelInfoServer.GetPersonnelViewInfoByName(dtTemp.Rows[38][7].ToString());

                if (GlobalObject.GeneralFunction.IsNullOrEmpty(线员工号))
                {
                    MessageDialog.ShowPromptMessage("文件中的下线员姓名在公司不唯一,无法获取到员工编号");
                    return;
                }

                string remark = dtTemp.Rows[35][2].ToString();

                remark += string.Format("【工号:{0}, 姓名:{1}从EXCEL文件中导入】", BasicInfo.LoginID, BasicInfo.LoginName);

                DataTable dt = new DataTable();

                dt.Columns.Add("TestType");         // 试验类型,如:基本功能、N挡磨合等
                dt.Columns.Add("TestItemName");     // 试验项目,如:密封性、传动平稳
                dt.Columns.Add("TestCondition");    // 试验条件,如:整个试验过程中
                dt.Columns.Add("TestRequirement");  // 试验要求,如:总成各结合面、外表面及油封刃口处不得有渗透现象
                dt.Columns.Add("TestData");         // 试验数据,如:0.5Mpa
                dt.Columns.Add("TestResult");       // 试验结论,如:合格

                string 检测项目     = "";
                string 试验项目     = "";
                string 试验条件     = "";
                string 试验要求     = "";
                string 检测数据     = "";
                string 试验项目测试结果 = "";
                string 试验项目备份   = "";

                for (int i = 3; i < 35; i++)
                {
                    if (!GlobalObject.GeneralFunction.IsNullOrEmpty(dtTemp.Rows[i][1].ToString()))
                    {
                        检测项目   = dtTemp.Rows[i][1].ToString();
                        试验项目   = "";
                        试验项目备份 = "";
                    }

                    if (!GlobalObject.GeneralFunction.IsNullOrEmpty(dtTemp.Rows[i][2].ToString()))
                    {
                        试验项目备份 = dtTemp.Rows[i][2].ToString();

                        if (!GlobalObject.GeneralFunction.IsNullOrEmpty(dtTemp.Rows[i][3].ToString()))
                        {
                            试验项目 = dtTemp.Rows[i][2].ToString() + "-" + dtTemp.Rows[i][3].ToString();
                        }
                        else
                        {
                            试验项目 = dtTemp.Rows[i][2].ToString();
                        }

                        试验条件 = "";
                    }
                    else if (!GlobalObject.GeneralFunction.IsNullOrEmpty(dtTemp.Rows[i][3].ToString()))
                    {
                        试验项目 = 试验项目备份 + "-" + dtTemp.Rows[i][3].ToString();
                        试验条件 = "";
                    }

                    if (!GlobalObject.GeneralFunction.IsNullOrEmpty(dtTemp.Rows[i][4].ToString()))
                    {
                        试验条件 = dtTemp.Rows[i][4].ToString();
                    }

                    试验要求     = dtTemp.Rows[i][5].ToString();
                    检测数据     = dtTemp.Rows[i][6].ToString();
                    试验项目测试结果 = dtTemp.Rows[i][7].ToString();

                    dt.Rows.Add(new object[] { 检测项目, 试验项目, 试验条件, 试验要求, 检测数据, 试验项目测试结果 });
                }

                CvtTestInfo testInfo = new CvtTestInfo(
                    productCode + " " + cvtNumber, 试验设备名称, 油品, 试验结果, 装配员工号, 线员工号, remark, dt);

                m_cvtTestDataService.SaveCVTExpData(testInfo);

                MessageDialog.ShowPromptMessage(string.Format("导入【{0}】文件成功!", openFileDialog1.FileName));
            }
            catch (Exception exce)
            {
                MessageDialog.ShowErrorMessage(exce.Message);
            }

            //for (int row = 0; row < dtTemp.Rows.Count; row++)
            //{
            //    for (int col = 0; col < dtTemp.Columns.Count; col++)
            //    {
            //        Console.Write("[{0}, {1}]:{2}\t", row, col, dtTemp.Rows[row][col].ToString());
            //    }

            //    Console.WriteLine();
            //}
        }
        private void txtInport_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                CursorControl.SetWaitCursor(this);
                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1.OpenFile());

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

                if (CheckTable(dtTemp))
                {
                    List <ZL_Database_Record> listRecord = new List <ZL_Database_Record>();

                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        if (dr["序列号"].ToString().Trim().Length == 0)
                        {
                            continue;
                        }

                        ZL_Database_Record m_lnqRecord = new ZL_Database_Record();

                        m_lnqRecord.BillNo           = openFileDialog1.FileName.Substring(0, openFileDialog1.FileName.LastIndexOf("\\") + 1) + dr["序列号"].ToString().Trim();
                        m_lnqRecord.CreationTime     = ServerTime.Time;
                        m_lnqRecord.AssemblyCartonNo = dr["总成箱号"].ToString().Trim();
                        m_lnqRecord.CauseAnalysis    = dr["原因分析"].ToString().Trim();
                        m_lnqRecord.FaultRatio       = dr["故障比例"].ToString().Trim();
                        m_lnqRecord.Provider         = dr["供应商"].ToString().Trim();
                        m_lnqRecord.FaultDescription = dr["故障描述"].ToString().Trim();
                        m_lnqRecord.FaultType        = dr["故障类型"].ToString().Trim();
                        m_lnqRecord.Finder           = dr["发现人员"].ToString().Trim();
                        m_lnqRecord.FindPlaces       = dr["发现场所"].ToString().Trim();
                        m_lnqRecord.FindRole         = dr["发现者"].ToString().Trim();
                        m_lnqRecord.GoodsCode        = dr["图号型号"].ToString().Trim();
                        m_lnqRecord.GoodsName        = dr["物品名称"].ToString().Trim();
                        m_lnqRecord.Spec             = dr["规格"].ToString().Trim();
                        m_lnqRecord.Mileage          = dr["行驶里程"].ToString().Trim() == "" ? 0 : Convert.ToDecimal(dr["行驶里程"].ToString().Trim());
                        m_lnqRecord.Model            = dr["型号"].ToString().Trim();
                        m_lnqRecord.OccurrenceTime   = dr["发生时间"].ToString().Trim() == ""? null :
                                                       (DateTime?)Convert.ToDateTime(dr["发生时间"].ToString().Trim());
                        m_lnqRecord.TreatmentCountermeasures = dr["处理对策"].ToString().Trim();
                        m_lnqRecord.Type    = dr["不良品类型"].ToString().Trim();
                        m_lnqRecord.Version = dr["版次"].ToString().Trim();

                        listRecord.Add(m_lnqRecord);
                    }

                    m_serverQylityDatabase.BatchInportInfo(listRecord);
                    MessageDialog.ShowPromptMessage("导入成功");
                }

                this.Cursor = System.Windows.Forms.Cursors.Arrow;
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
            }


            btnRefresh_Click(null, null);
        }
Пример #20
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
        }
Пример #21
0
        private void btnInput_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null)
                {
                    return;
                }

                if (!dtTemp.Columns.Contains("图号型号"))
                {
                    throw new Exception("文件无【图号型号】列名");
                }

                if (!dtTemp.Columns.Contains("物品名称"))
                {
                    throw new Exception("文件无【物品名称】列名");
                }

                if (!dtTemp.Columns.Contains("规格"))
                {
                    throw new Exception("文件无【规格】列名");
                }

                if (!dtTemp.Columns.Contains("供应商"))
                {
                    throw new Exception("文件无【供应商】列名");
                }

                if (!dtTemp.Columns.Contains("单价"))
                {
                    throw new Exception("文件无【单价】列名");
                }

                if (!dtTemp.Columns.Contains("税率"))
                {
                    throw new Exception("文件无【税率】列名");
                }

                if (!dtTemp.Columns.Contains("有效期开始时间"))
                {
                    throw new Exception("文件无【有效期开始时间】列名");
                }

                if (!dtTemp.Columns.Contains("有效期结束时间"))
                {
                    throw new Exception("文件无【有效期结束时间】列名");
                }


                List <Bus_PurchasingMG_UnitPriceList> lstTemp = new List <Bus_PurchasingMG_UnitPriceList>();

                foreach (DataRow dr in dtTemp.Rows)
                {
                    if ((dr["图号型号"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["图号型号"].ToString())) &&
                        (dr["物品名称"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["物品名称"].ToString())) &&
                        (dr["规格"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["规格"].ToString())))
                    {
                        continue;
                    }

                    Bus_PurchasingMG_UnitPriceList tempInfo = new Bus_PurchasingMG_UnitPriceList();

                    string goodsMessage = "【图号型号】:" + (dr["图号型号"] == null ? "" : dr["图号型号"].ToString().Trim()).ToString()
                                          + "【物品名称】:" + (dr["物品名称"] == null ? "" : dr["物品名称"].ToString().Trim()).ToString()
                                          + "【规格】:" + (dr["规格"] == null ? "" : dr["规格"].ToString().Trim()).ToString();

                    View_F_GoodsPlanCost goodsInfo = UniversalFunction.GetGoodsInfo(dr["图号型号"] == null ? "" : dr["图号型号"].ToString().Trim(),
                                                                                    dr["物品名称"] == null ? "" : dr["物品名称"].ToString().Trim(),
                                                                                    dr["规格"] == null ? "" : dr["规格"].ToString().Trim());

                    if (goodsInfo == null)
                    {
                        throw new Exception("未找到对应的系统物品:" + goodsMessage);
                    }

                    //if (goodsInfo.禁用)
                    //{
                    //    throw new Exception("此物品已被禁用无法导入:" + goodsMessage);
                    //}

                    tempInfo.GoodsID = goodsInfo.序号;

                    string        strProvicer = dr["供应商"] == null ? "" : dr["供应商"].ToString();
                    View_Provider provider    = UniversalFunction.GetProviderInfo(strProvicer);

                    if (provider == null)
                    {
                        throw new Exception("未找到对应的系统供应商:" + strProvicer);
                    }

                    if (!provider.是否在用)
                    {
                        throw new Exception("【系统供应商】:" + strProvicer + " 被禁用,无法导入");
                    }

                    tempInfo.Provider  = provider.供应商编码;
                    tempInfo.Rate      = dr["税率"] == null || dr["税率"].ToString().Trim() == "" ? 0 : Convert.ToInt32(dr["税率"]);
                    tempInfo.UnitPrice = dr["单价"] == null || dr["单价"].ToString().Trim() == "" ? 0 : Convert.ToDecimal(dr["单价"]);

                    if (dr["有效期开始时间"] == null || dr["有效期开始时间"].ToString().Trim() == "")
                    {
                        throw new Exception("有效期开始时间有误:" + goodsMessage);
                    }
                    else
                    {
                        tempInfo.ValidityStart = Convert.ToDateTime(dr["有效期开始时间"]).Date;
                    }

                    if (dr["有效期结束时间"] == null || dr["有效期结束时间"].ToString().Trim() == "")
                    {
                        throw new Exception("有效期结束时间有误:" + goodsMessage);
                    }
                    else
                    {
                        tempInfo.ValidityEnd = Convert.ToDateTime(dr["有效期结束时间"]).Date;
                    }

                    lstTemp.Add(tempInfo);
                }

                _Service_UnitList.SaveInfo(lstTemp);
                MessageDialog.ShowPromptMessage("导入并保存成功");
                DataGridViewShow();
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Пример #22
0
        private void btnResolve_InProduct_Click(object sender, EventArgs e)
        {
            try
            {
                string yearMonth = "";

                择年月 frm = new  择年月();

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    yearMonth = frm._Str_YearMonth;
                }
                else
                {
                    return;
                }

                //DataTable tempTable = _Service_InProcutReport.GetAllInProductInfo(零件供应商耗用报表.Name, yearMonth);

                //if (tempTable != null && tempTable.Rows.Count > 0)
                //{
                //    if (MessageDialog.ShowEnquiryMessage("年月:【"+ yearMonth +"】,已存在记录,重复导入"))
                //    {

                //    }
                //}

                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null)
                {
                    return;
                }

                if (!dtTemp.Columns.Contains("图号型号"))
                {
                    throw new Exception("文件无【图号型号】列名");
                }

                if (!dtTemp.Columns.Contains("物品名称"))
                {
                    throw new Exception("文件无【物品名称】列名");
                }

                if (!dtTemp.Columns.Contains("规格"))
                {
                    throw new Exception("文件无【规格】列名");
                }

                if (!dtTemp.Columns.Contains("耗用数"))
                {
                    throw new Exception("文件无【耗用数】列名");
                }

                if (!dtTemp.Columns.Contains("供应商"))
                {
                    throw new Exception("文件无【供应商】列名");
                }

                List <Bus_WorkShop_InProduct_Resolve> lstInfo = new List <Bus_WorkShop_InProduct_Resolve>();

                for (int i = 0; i < dtTemp.Rows.Count; i++)
                {
                    int goodsID = UniversalFunction.GetGoodsID(dtTemp.Rows[i]["图号型号"].ToString(),
                                                               dtTemp.Rows[i]["物品名称"].ToString(), dtTemp.Rows[i]["规格"].ToString());

                    if (goodsID == 0)
                    {
                        throw new Exception(string.Format("第【{0}】行,图号型号:{1},物品名称:{2},规格:{3},无法找到匹配的物品ID", i.ToString(),
                                                          dtTemp.Rows[i]["图号型号"].ToString(), dtTemp.Rows[i]["物品名称"].ToString(), dtTemp.Rows[i]["规格"].ToString()));
                    }

                    Bus_WorkShop_InProduct_Resolve tempInfo = new Bus_WorkShop_InProduct_Resolve();
                    tempInfo.F_Id      = Guid.NewGuid().ToString();
                    tempInfo.GoodsID   = goodsID;
                    tempInfo.Provider  = dtTemp.Rows[i]["供应商"].ToString();
                    tempInfo.YearMonth = yearMonth;

                    decimal goodsCount = 0;
                    Decimal.TryParse(dtTemp.Rows[i]["耗用数"] == null ? "" : dtTemp.Rows[i]["耗用数"].ToString(), out goodsCount);
                    tempInfo.GoodsCount = goodsCount;

                    lstInfo.Add(tempInfo);
                }

                _Service_InProcutReport.InputResolveInfo(lstInfo);
                MessageDialog.ShowPromptMessage("导入成功");
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return;
            }
        }
Пример #23
0
        private void btnInput_BOM_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtGoodsCode_BOM.Tag == null || txtGoodsCode_BOM.Text.Trim().Length == 0)
                {
                    throw new Exception("请选择【总成/分总成】");
                }

                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null)
                {
                    return;
                }

                if (!dtTemp.Columns.Contains("图号型号"))
                {
                    throw new Exception("文件无【图号型号】列名");
                }

                if (!dtTemp.Columns.Contains("物品名称"))
                {
                    throw new Exception("文件无【物品名称】列名");
                }

                if (!dtTemp.Columns.Contains("规格"))
                {
                    throw new Exception("文件无【规格】列名");
                }

                if (!dtTemp.Columns.Contains("用量"))
                {
                    throw new Exception("文件无【用量】列名");
                }

                List <Bus_WorkShop_InProduct_Bom> lstInfo = new List <Bus_WorkShop_InProduct_Bom>();

                for (int i = 0; i < dtTemp.Rows.Count; i++)
                {
                    int goodsID = UniversalFunction.GetGoodsID(dtTemp.Rows[i]["图号型号"].ToString(),
                                                               dtTemp.Rows[i]["物品名称"].ToString(), dtTemp.Rows[i]["规格"].ToString());

                    if (goodsID == 0)
                    {
                        throw new Exception(string.Format("第【{0}】行,图号型号:{1},物品名称:{2},规格:{3},无法找到匹配的物品ID", i.ToString(),
                                                          dtTemp.Rows[i]["图号型号"].ToString(), dtTemp.Rows[i]["物品名称"].ToString(), dtTemp.Rows[i]["规格"].ToString()));
                    }

                    Bus_WorkShop_InProduct_Bom bom = new Bus_WorkShop_InProduct_Bom();
                    bom.F_Id           = Guid.NewGuid().ToString();
                    bom.GoodsID        = goodsID;
                    bom.ProductGoodsID = Convert.ToInt32(txtGoodsCode_BOM.Tag);

                    decimal goodsCount = 0;
                    Decimal.TryParse(dtTemp.Rows[i]["用量"] == null ? "" : dtTemp.Rows[i]["用量"].ToString(), out goodsCount);
                    bom.UseCount = goodsCount;

                    lstInfo.Add(bom);
                }

                _Service_InProcutReport.InputBom(lstInfo);
                MessageDialog.ShowPromptMessage("导入成功");
                btnSelect_BOM_Click(null, null);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return;
            }
        }
Пример #24
0
        private void 导入toolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

                if (dtTemp == null)
                {
                    return;
                }

                if (CheckTable(dtTemp))
                {
                    #region 分析排班人员的打卡时间

                    List <HR_AttendanceMachineDataList> lstMachineDate = new List <HR_AttendanceMachineDataList>();

                    for (int i = 0; i < dtTemp.Rows.Count; i++)
                    {
                        string workID     = "";
                        string recordTime = "";
                        string beforTime  = "";
                        string afterTime  = "";

                        if (dtTemp.Columns.Contains("工号"))
                        {
                            workID = dtTemp.Rows[i]["工号"].ToString();

                            if (workID == "")
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (GlobalObject.GeneralFunction.IsNullOrEmptyObject(dtTemp.Rows[i]["日期"]) ||
                                GlobalObject.GeneralFunction.IsNullOrEmptyObject(dtTemp.Rows[i]["时间"]))
                            {
                                continue;
                            }

                            if (dtTemp.Rows[i]["登记号码"].ToString() == "")
                            {
                                continue;
                            }

                            string str = m_attendanceMachineServer.GetCardIDWorkIDMapping(dtTemp.Rows[i]["登记号码"].ToString());

                            if (str.Equals("0"))
                            {
                                //MessageDialog.ShowPromptMessage("【" + dtTemp.Rows[i]["登记号码"].ToString() + "】登记号码没有在映射表中!");
                                //return;
                                continue;
                            }

                            workID = str;
                        }

                        DateTime date           = Convert.ToDateTime(dtTemp.Rows[i]["日期"].ToString());
                        DateTime beforTimeTemp  = date.AddDays(-1);
                        DateTime afterTimeTemp  = Convert.ToDateTime(dtTemp.Rows[i]["日期"].ToString()).AddDays(1);
                        string[] recordTimeTemp = dtTemp.Rows[i]["时间"].ToString().Split(' ');

                        HR_AttendanceSetting attendanceSet = m_attendanceSchemeServer.GetAttendanceSettingByWorkID(workID);
                        string[]             schemeCode    = attendanceSet.SchemeCode.Split(' ');
                        string mode = m_attendanceSchemeServer.GetAttendanceSchemeByCode(schemeCode[0]).AttendanceMode;

                        if (mode.Contains("自然月排班考勤"))
                        {
                            DataTable dtWorkSchedule = m_workSchedulingServer.GetWorkSchedulingByWorkIDAndDate(workID, Convert.ToDateTime(dtTemp.Rows[i]["日期"].ToString()));

                            if (dtWorkSchedule != null && dtWorkSchedule.Rows.Count > 0)
                            {
                                if (!Convert.ToBoolean(dtWorkSchedule.Rows[0]["isholiday"].ToString()))
                                {
                                    string beginTime     = Convert.ToDateTime(dtWorkSchedule.Rows[0]["beginTime"].ToString()).ToShortTimeString();
                                    string punchInBegin  = Convert.ToDateTime(dtWorkSchedule.Rows[0]["punchInBeginTime"].ToString()).ToShortTimeString();
                                    string punchInEnd    = Convert.ToDateTime(dtWorkSchedule.Rows[0]["punchInEndTime"].ToString()).ToShortTimeString();
                                    string punchOutBegin = Convert.ToDateTime(dtWorkSchedule.Rows[0]["punchOutBeginTime"].ToString()).ToShortTimeString();
                                    string punchOutEnd   = Convert.ToDateTime(dtWorkSchedule.Rows[0]["punchOutEndTime"].ToString()).ToShortTimeString();

                                    if ((Convert.ToDateTime(beginTime) - Convert.ToDateTime(punchInBegin)).Hours < 0)
                                    {
                                        if (i != dtTemp.Rows.Count - 1)
                                        {
                                            string str = dtTemp.Rows[i + 1]["时间"].ToString();

                                            if (!str.Equals("0"))
                                            {
                                                string[] timeTemp = str.Split(' ');

                                                if (recordTimeTemp.Length == 0)
                                                {
                                                    beforTime = afterTimeTemp.Year + "年" + afterTimeTemp.Month + "月" + afterTimeTemp.Day + "日" + timeTemp[0];
                                                    afterTime = timeTemp[1];
                                                }
                                                else
                                                {
                                                    afterTime = timeTemp[0];
                                                }
                                            }
                                        }
                                    }

                                    if (Convert.ToInt32(dtWorkSchedule.Rows[0]["endOffSetDays"].ToString()) > 0)
                                    {
                                        afterTimeTemp = Convert.ToDateTime(dtTemp.Rows[i]["日期"].ToString()).AddDays(
                                            Convert.ToInt32(dtWorkSchedule.Rows[0]["endOffSetDays"].ToString()));

                                        string str = dtTemp.Rows[i + Convert.ToInt32(dtWorkSchedule.Rows[0]["endOffSetDays"].ToString())]["时间"].ToString();

                                        if (!str.Equals("0"))
                                        {
                                            string[] timeTemp = str.Split(' ');

                                            if (timeTemp[0] != "")
                                            {
                                                if (Convert.ToDateTime(timeTemp[0]) < Convert.ToDateTime(punchOutEnd))
                                                {
                                                    afterTime = timeTemp[0];
                                                }
                                            }
                                        }
                                    }

                                    if (beforTime != "")
                                    {
                                        if (!recordTime.Contains(beforTime))
                                        {
                                            recordTime = beforTime + " ";
                                        }
                                    }

                                    for (int j = 0; j < recordTimeTemp.Length; j++)
                                    {
                                        if (recordTimeTemp[j] != "")
                                        {
                                            if (j != 0)
                                            {
                                                if (recordTimeTemp[j - 1] == recordTimeTemp[j])
                                                {
                                                    continue;
                                                }

                                                if (Convert.ToDateTime(recordTimeTemp[j]).Hour - Convert.ToDateTime(recordTimeTemp[j - 1]).Hour == 0
                                                    &&
                                                    Convert.ToDateTime(recordTimeTemp[j]).Minute - Convert.ToDateTime(recordTimeTemp[j - 1]).Minute < 5)
                                                {
                                                    continue;
                                                }
                                            }

                                            recordTime += date.Year + "年" + date.Month + "月" + date.Day + "日" + recordTimeTemp[j] + " ";
                                        }
                                    }

                                    if (afterTime != "")
                                    {
                                        string strAfter = afterTimeTemp.Year + "年" + afterTimeTemp.Month + "月" + afterTimeTemp.Day + "日" + afterTime;

                                        if (!recordTime.Contains(strAfter))
                                        {
                                            recordTime += afterTimeTemp.Year + "年" + afterTimeTemp.Month + "月" + afterTimeTemp.Day + "日" + afterTime + " ";
                                        }
                                    }
                                }
                                else
                                {
                                    for (int j = 0; j < recordTimeTemp.Length; j++)
                                    {
                                        if (recordTimeTemp[j] != "")
                                        {
                                            if (j != 0)
                                            {
                                                if (recordTimeTemp[j - 1] == recordTimeTemp[j])
                                                {
                                                    continue;
                                                }

                                                if (Convert.ToDateTime(recordTimeTemp[j]).Hour - Convert.ToDateTime(recordTimeTemp[j - 1]).Hour == 0
                                                    &&
                                                    Convert.ToDateTime(recordTimeTemp[j]).Minute - Convert.ToDateTime(recordTimeTemp[j - 1]).Minute < 5)
                                                {
                                                    continue;
                                                }
                                            }

                                            recordTime += date.Year + "年" + date.Month + "月" + date.Day + "日" + recordTimeTemp[j] + " ";
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int j = 0; j < recordTimeTemp.Length; j++)
                                {
                                    if (recordTimeTemp[j] != "")
                                    {
                                        if (j != 0)
                                        {
                                            if (recordTimeTemp[j - 1] == recordTimeTemp[j])
                                            {
                                                continue;
                                            }

                                            if (Convert.ToDateTime(recordTimeTemp[j]).Hour - Convert.ToDateTime(recordTimeTemp[j - 1]).Hour == 0 &&
                                                Convert.ToDateTime(recordTimeTemp[j]).Minute - Convert.ToDateTime(recordTimeTemp[j - 1]).Minute < 5)
                                            {
                                                continue;
                                            }
                                        }

                                        recordTime += date.Year + "年" + date.Month + "月" + date.Day + "日" + recordTimeTemp[j] + " ";
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int j = 0; j < recordTimeTemp.Length; j++)
                            {
                                if (recordTimeTemp[j] != "")
                                {
                                    if (j != 0)
                                    {
                                        if (recordTimeTemp[j - 1] == recordTimeTemp[j])
                                        {
                                            continue;
                                        }

                                        if (Convert.ToDateTime(recordTimeTemp[j]).Hour - Convert.ToDateTime(recordTimeTemp[j - 1]).Hour == 0 &&
                                            Convert.ToDateTime(recordTimeTemp[j]).Minute - Convert.ToDateTime(recordTimeTemp[j - 1]).Minute < 5)
                                        {
                                            continue;
                                        }
                                    }

                                    recordTime += date.Year + "年" + date.Month + "月" + date.Day + "日" + recordTimeTemp[j] + " ";
                                }
                            }
                        }

                        HR_AttendanceMachineDataList machineDataList = new HR_AttendanceMachineDataList();

                        machineDataList.Date       = date;
                        machineDataList.RecordTime = recordTime;
                        machineDataList.WorkID     = workID;
                        machineDataList.Remark     = "";

                        lstMachineDate.Add(machineDataList);
                    }
                    #endregion

                    m_attendanceMachineServer.InsertAttendanceMachine(lstMachineDate);
                    MessageDialog.ShowPromptMessage("导入成功!");
                }

                RefreshDataGridView();

                if (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Columns["单据号"].Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Пример #25
0
        private void btn_Import_Click(object sender, EventArgs e)
        {
            //string error = "";

            DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1);

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

            if (!dtTemp.Columns.Contains("图号型号"))
            {
                MessageDialog.ShowPromptMessage("无【图号型号】列");
            }

            if (!dtTemp.Columns.Contains("物品名称"))
            {
                MessageDialog.ShowPromptMessage("无【物品名称】列");
            }

            if (!dtTemp.Columns.Contains("规格"))
            {
                MessageDialog.ShowPromptMessage("无【规格】列");
            }

            if (!dtTemp.Columns.Contains("基数"))
            {
                MessageDialog.ShowPromptMessage("无【基数】列");
            }

            if (!dtTemp.Columns.Contains("一次性整台份发料"))
            {
                MessageDialog.ShowPromptMessage("无【一次性整台份发料】列");
            }

            m_listDebitSchedule = new List <View_S_DebitSchedule>();

            foreach (DataRow dr in dtTemp.Rows)
            {
                View_S_DebitSchedule tempLnq = new View_S_DebitSchedule();

                int goodsID = UniversalFunction.GetGoodsID(dr["图号型号"].ToString(), dr["物品名称"].ToString(), dr["规格"].ToString());

                if (goodsID != 0)
                {
                    tempLnq.物品ID = goodsID;

                    foreach (View_S_DebitSchedule item in m_listDebitSchedule)
                    {
                        if (item.物品ID == tempLnq.物品ID)
                        {
                            MessageDialog.ShowPromptMessage(UniversalFunction.GetGoodsMessage(tempLnq.物品ID)
                                                            + "已存在一条记录,不能插入重复记录");
                        }
                    }
                }
                else
                {
                    MessageDialog.ShowPromptMessage("图号:" + dr["图号型号"].ToString()
                                                    + " 名称:" + dr["物品名称"].ToString() + " 规格:" + dr["规格"].ToString() + " 不存在于系统中");
                    return;
                }

                if (dr["基数"] == null || Convert.ToInt32(dr["基数"]) == 0)
                {
                    MessageDialog.ShowPromptMessage("图号:" + dr["图号型号"].ToString()
                                                    + " 名称:" + dr["物品名称"].ToString() + " 规格:" + dr["规格"].ToString() + " 【基数】不符合要求,请重新检查");
                }
                else
                {
                    tempLnq.基数 = Convert.ToDecimal(dr["基数"]);
                }

                if (dr["一次性整台份发料"] == null)
                {
                    MessageDialog.ShowPromptMessage("图号:" + dr["图号型号"].ToString()
                                                    + " 名称:" + dr["物品名称"].ToString() + " 规格:" + dr["规格"].ToString() + " 【一次性整台份发料】不符合要求,请重新检查");
                }
                else
                {
                    tempLnq.一次性整台份发料 = dr["一次性整台份发料"].ToString().Trim() == "是" ? true : false;
                }

                tempLnq.单据号  = txtSDBNo.Text;
                tempLnq.规格   = dr["规格"].ToString();
                tempLnq.图号型号 = dr["图号型号"].ToString();
                tempLnq.物品名称 = dr["物品名称"].ToString();
                tempLnq.总成编码 = txtEditionCode.Text;
                tempLnq.适用范围 = cmbApplicable.Text;

                m_listDebitSchedule.Add(tempLnq);
            }

            RefreshDataGridView(m_listDebitSchedule);
            MessageDialog.ShowPromptMessage("导入完成");
        }