Example #1
0
        public List <NVLTheoLSX> ListNVL(string code, string No)
        {
            List <NVLTheoLSX> _listNVL = new List <NVLTheoLSX>();
            sqlERPCON         query    = new sqlERPCON();
            StringBuilder     strSQL   = new StringBuilder();
            DataTable         dt       = new DataTable();

            strSQL.Append("select TB001,TB002, TB003,TB004,TB005,TB006 from MOCTB where TB006 ='****' and TB018 ='Y' and ");
            strSQL.Append(" TB001 = '" + code + "' and ");
            strSQL.Append(" TB002 = '" + No + "'");
            query.sqlDataAdapterFillDatatable(strSQL.ToString(), ref dt);
            //Load data into list
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                NVLTheoLSX nVL = new NVLTheoLSX();

                nVL.code           = dt.Rows[i]["TB001"].ToString();
                nVL.No             = dt.Rows[i]["TB002"].ToString();
                nVL.NVL_TB003      = dt.Rows[i]["TB003"].ToString();
                nVL.NVLCan_TB004   = dt.Rows[i]["TB004"].ToString() != "" ? double.Parse(dt.Rows[i]["TB004"].ToString()):0;
                nVL.NVLLanh_TB005  = dt.Rows[i]["TB005"].ToString() != "" ? double.Parse(dt.Rows[i]["TB005"].ToString()) : 0;
                nVL.NVLPercentLanh = (nVL.NVLCan_TB004 != 0) ? (nVL.NVLLanh_TB005 / nVL.NVLCan_TB004) :((nVL.NVLCan_TB004 == nVL.NVLLanh_TB005)?1:0);
                nVL.CD_TB006       = dt.Rows[i]["TB006"].ToString();
                _listNVL.Add(nVL);
            }


            return(_listNVL);
        }
Example #2
0
        public List <LSX_SFTTA> ListSFTTA(string code, string No)
        {
            List <LSX_SFTTA> lSX_SFTTAs = new List <LSX_SFTTA>();
            sqlERPCON        query      = new sqlERPCON();
            StringBuilder    strSQL     = new StringBuilder();
            DataTable        dt         = new DataTable();

            strSQL.Append("select TA001,TA002,TA003,TA004,TA008,TA009,TA010,TA011,TA012 from SFCTA where TA003 = '0010' and  ");
            strSQL.Append(" TA001 = '" + code + "' and ");
            strSQL.Append(" TA002 = '" + No + "'");
            query.sqlDataAdapterFillDatatable(strSQL.ToString(), ref dt);
            //Load data into list
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                LSX_SFTTA sFTTA = new LSX_SFTTA();
                sFTTA.code              = dt.Rows[i]["TA001"].ToString();
                sFTTA.No                = dt.Rows[i]["TA002"].ToString();
                sFTTA.MaSX_TA003        = dt.Rows[i]["TA003"].ToString();
                sFTTA.MaSX_TA004        = dt.Rows[i]["TA004"].ToString();
                sFTTA.NgayBatdau_TA008  = dt.Rows[i]["TA008"].ToString();
                sFTTA.NgayKetThuc_TA009 = dt.Rows[i]["TA009"].ToString();
                sFTTA.SLKeHoach_TA010   = dt.Rows[i]["TA010"].ToString() != "" ? double.Parse(dt.Rows[i]["TA010"].ToString()) : 0;
                sFTTA.SLOutput_TA011    = dt.Rows[i]["TA011"].ToString() != "" ? double.Parse(dt.Rows[i]["TA011"].ToString()) : 0;
                sFTTA.SLBaoPhe_TA012    = dt.Rows[i]["TA012"].ToString() != "" ? double.Parse(dt.Rows[i]["TA012"].ToString()) : 0;
                lSX_SFTTAs.Add(sFTTA);
            }
            return(lSX_SFTTAs);
        }
Example #3
0
        public static void exportcsvToPLC(string linkListProduct)
        {
            try
            {
                string path = linkListProduct;
                File.Delete(path + "ListProduct.csv");
                StringBuilder sql = new StringBuilder();
                sql.Append(@"
select TA001+'-'+RTRIM(TA002)+';'+TA003+';'+TA004+';'+ RTRIM(TA006),  RTRIM(TC047),RTRIM(TA010),  RTRIM(TA011), RTRIM(TA012)  ,TA001,TA002,TA003,TA004, TA006 from SFCTA 
left join SFCTC on TA001 = TC004 and TA002 = TC005
where 1=1
and TA004 = 'B01'
and TA011+TA012 <TA010
group by TA001,TA002,TA003,TA004, TA006, TA010, TA011,TA012, TC047
");
                DataTable dtshow = new DataTable();
                sqlERPCON data   = new sqlERPCON();
                data.sqlDataAdapterFillDatatable(sql.ToString(), ref dtshow);

                StringBuilder builder     = new StringBuilder();
                int           rowcount    = dtshow.Rows.Count;
                int           columncount = dtshow.Columns.Count;
                List <string> cols        = new List <string>();

                // builder.AppendLine(string.Join("\t", cols.ToArray()));
                for (int i = 0; i < rowcount; i++)
                {
                    cols = new List <string>();
                    for (int j = 0; j < 5; j++) //Chỉ lay 4 cọt đâu thôi, yêu cầu của Đức
                    {
                        cols.Add(dtshow.Rows[i][j].ToString() + @",");
                    }
                    builder.AppendLine(string.Join("", cols.ToArray()));
                }
                System.IO.File.WriteAllText(path + "ListProduct.csv", builder.ToString());
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "exportcsvToPLC()", ex.Message);
            }
        }