Beispiel #1
0
        public void LoadDepartment()
        {
            if (DepartmentArchives != null)
            {
                DepartmentArchives.Clear();
            }
            XmlReader reader = new XmlTextReader(DepartmentArchivePath);

            try
            {
                DepartmentArchives departmentArchives = XMLHelper.UnSerializer(reader, typeof(DepartmentArchives)) as DepartmentArchives;
                if (departmentArchives != null)
                {
                    foreach (var value in departmentArchives)
                    {
                        DepartmentArchives.Add(value);
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
            }
        }
Beispiel #2
0
        private void ImportAccvoch(DataRow[] dataRow, string filePath, List <string> infos)
        {
            string id = string.Empty;

            try
            {
                int ino_id = 0;
                Dictionary <string, string> keys = new Dictionary <string, string>();
                keys.Add("csign", dataRow[0]["凭证类别"].ToString());
                keys.Add("ibook", "0");
                DataSet ds = SqlHelper.Query(LoginSettingInfo.SqlConnectionString, "GL_accvouch", "ino_id", keys, "ino_id");
                if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    ino_id = 1;
                }
                else
                {
                    DataTable dt = ds.Tables[0];
                    ino_id = int.Parse(dt.Rows[dt.Rows.Count - 1]["ino_id"].ToString()) + 1;
                }
                int count = dataRow.Length;
                for (int i = 0; i < count; ++i)
                {
                    Accvouch accvouch = new Accvouch();
                    accvouch.ino_id   = ino_id;
                    accvouch.cDefine1 = dataRow[i]["凭证ID"].ToString();
                    id               = accvouch.cDefine1;
                    accvouch.csign   = dataRow[i]["凭证类别"].ToString();
                    accvouch.cdigest = dataRow[i]["摘要"].ToString();
                    accvouch.ccode   = CodeArchives.FindByCode(dataRow[i]["科目编码"].ToString());
                    if (dataRow[i]["借方金额"] != null && dataRow[i]["借方金额"].ToString().Length > 0)
                    {
                        accvouch.md = double.Parse(dataRow[i]["借方金额"].ToString());
                    }
                    if (dataRow[i]["贷方金额"] != null && dataRow[i]["贷方金额"].ToString().Length > 0)
                    {
                        accvouch.mc = double.Parse(dataRow[i]["贷方金额"].ToString());
                    }
                    if (dataRow[i]["所附单据数"] != null && dataRow[i]["所附单据数"].ToString().Length > 0)
                    {
                        accvouch.idoc = int.Parse(dataRow[i]["所附单据数"].ToString());
                    }
                    if (dataRow[i]["结算方式编码"] != null && dataRow[i]["结算方式编码"].ToString().Length > 0)
                    {
                        accvouch.csettle = dataRow[i]["结算方式编码"].ToString();
                    }
                    if (dataRow[i]["部门编码"] != null && dataRow[i]["部门编码"].ToString().Length > 0)
                    {
                        accvouch.cdept_id = DepartmentArchives.FindByDepartmentCode(dataRow[i]["部门编码"].ToString());
                    }
                    if (dataRow[i]["职员编码"] != null && dataRow[i]["职员编码"].ToString().Length > 0)
                    {
                        accvouch.cperson_id = dataRow[i]["职员编码"].ToString();
                    }
                    if (dataRow[i]["客户编码"] != null && dataRow[i]["客户编码"].ToString().Length > 0)
                    {
                        accvouch.ccus_id = CustomerArchives.FindByCustomerCode(dataRow[i]["客户编码"].ToString());
                    }
                    if (dataRow[i]["供应商编码"] != null && dataRow[i]["供应商编码"].ToString().Length > 0)
                    {
                        accvouch.csup_id = VendorArchives.FindByVendorCode(dataRow[i]["供应商编码"].ToString());
                    }
                    if (dataRow[i]["项目大类编码"] != null && dataRow[i]["项目大类编码"].ToString().Length > 0)
                    {
                        accvouch.citem_class = dataRow[i]["项目大类编码"].ToString();
                    }
                    if (dataRow[i]["项目编码"] != null && dataRow[i]["项目编码"].ToString().Length > 0)
                    {
                        accvouch.citem_id = dataRow[i]["项目编码"].ToString();
                    }
                    if (dataRow[i]["业务员"] != null && dataRow[i]["业务员"].ToString().Length > 0)
                    {
                        accvouch.cname = dataRow[i]["业务员"].ToString();
                    }
                    accvouch.dbill_date = DateTime.Parse(LoginInfo.LoginDate.ToShortDateString());
                    accvouch.cbill      = LoginInfo.UserName;
                    accvouch.inid       = i + 1;
                    ImportAccvochToU8(accvouch, infos);
                }
            }
            catch (Exception ex)
            {
                infos.Add("凭证ID:" + id + "导入失败!" + "错误提示:" + ex.Message);
                Dictionary <string, string> wheres = new Dictionary <string, string>();
                wheres.Add("cDefine1", id);
                SqlHelper.Delete(LoginSettingInfo.SqlConnectionString, "GL_accvouch", wheres);
                Dictionary <string, string> values = new Dictionary <string, string>();
                values.Add("备注", ex.Message);
                wheres.Clear();
                wheres.Add("凭证ID", id);
                ExcelHelper.UpdateByODBC(filePath, "Sheet1", values, wheres);
            }
        }