Esempio n. 1
0
 private void vs_EnabledChanged(object sender, EventArgs e)
 {
     txt1.Text = vs1.Cols[txt1.Tag + ""].Caption;
     txt2.Text = vs1.Cols[txt2.Tag + ""].Caption;
     txt3.Text = vs1.Cols[txt3.Tag + ""].Caption;
     vs.AutoSizeCols();
 }
Esempio n. 2
0
        private void Init_Tree()
        {
            if (vs.Row < 1)
            {
                vs1.Rows.Count = 1;
                return;
            }
            ar = new ArrayList();
            ar.Add(null);
            string USER_ID = vs.Rows[vs.Row]["USER_ID"] + "";

            CheckSEC(USER_ID);
            vs1.Styles["Normal"].BackColor       = System.Drawing.Color.WhiteSmoke;
            vs1.Styles["Normal"].Border.Color    = System.Drawing.Color.WhiteSmoke;
            vs1.Styles["EmptyArea"].BackColor    = System.Drawing.Color.WhiteSmoke;
            vs1.Styles["EmptyArea"].Border.Color = System.Drawing.Color.WhiteSmoke;
            vs1.Rows.Count = 1;
            Node a;

            a = vs1.Rows.InsertNode(vs1.Rows.Count, 0);
            ar.Add(a);
            vs1.Rows[vs1.Rows.Count - 1]["DEP_NM"]    = T_String.GetDataFromSQL("COM_N2", "FILA01A", "ACT_BT=1");
            vs1.Rows[vs1.Rows.Count - 1]["ALL_BT"]    = false;
            vs1.Rows[vs1.Rows.Count - 1].AllowEditing = false;
            Init_TreeDetail("(DEP_HG is null OR DEP_HG='')", 1, a, USER_ID);
            vs1.AutoSizeCols();
        }
Esempio n. 3
0
 private void frmTaAddfor_Load(object sender, System.EventArgs e)
 {
     vs.Cols.Count   = 3;
     vs.Cols[1].Name = "COL_NM";
     vs.Cols[2].Name = "COL_MM";
     vs.Rows.Count   = 1;
     Func.RecordSet rs = new RecordSet("Select * from GP_SYS_SHIFT", PublicFunction.C_con);
     for (int i = 0; i < rs.rows; i++)
     {
         vs.Rows.Count++;
         vs.Rows[vs.Rows.Count - 1][0]        = vs.Rows.Count - 1;
         vs.Rows[vs.Rows.Count - 1]["COL_NM"] = rs.record(i, "TYP_ID");
         vs.Rows[vs.Rows.Count - 1]["COL_MM"] = rs.record(i, "TYP_NM");
     }
     rs = new RecordSet("Select * from FILC07A", PublicFunction.C_con);
     for (int i = 0; i < rs.rows; i++)
     {
         vs.Rows.Count++;
         vs.Rows[vs.Rows.Count - 1][0]        = vs.Rows.Count - 1;
         vs.Rows[vs.Rows.Count - 1]["COL_NM"] = rs.record(i, "COL_NM");
         vs.Rows[vs.Rows.Count - 1]["COL_MM"] = rs.record(i, "COL_MM");
     }
     vs.AutoSizeCols();
     Basic.Function.PublicFunction.L_Init_Label(this);
 }
Esempio n. 4
0
        private void vs_EnabledChanged(object sender, EventArgs e)
        {
            string sql = "Select * from FILD05A order by MON_QT DESC";

            Func.RecordSet rs = new Func.RecordSet(sql, PublicFunction.C_con);
            vs1.Cols.Count = rs.rows + 1;
            vs1.Rows.Count = 2;
            for (int i = 1; i <= 12; i++)
            {
                vs.Cols["COL_" + i.ToString("00")].Visible = false;
            }
            for (int i = 0; i < rs.rows; i++)
            {
                try
                {
                    vs1.Cols[i + 1].Name    = rs.record(i, "COL_NO");
                    vs1.Cols[i + 1].Caption = T_String.IsNullTo00(rs.record(i, "MON_QT")).ToString("#,###");

                    vs.Cols[rs.record(i, "COL_NO")].Visible = true;
                    vs.Cols[rs.record(i, "COL_NO")].Caption = T_String.IsNullTo00(rs.record(i, "MON_QT")).ToString("#,###");
                }
                catch {}
            }
            txt1.Text = vs.Cols[txt1.Tag + ""].Caption;
            txt2.Text = vs.Cols[txt2.Tag + ""].Caption;
//			//txt3.Text=vs.Cols[txt3.Tag+""].Caption;
            vs.AutoSizeCols();
        }
Esempio n. 5
0
        private void UpdateTotals()
        {
            // clear existing totals
            _flex.Subtotal(AggregateEnum.Clear);

            // calculate subtotals (three levels, totals on every column)
            for (int c = 3; c < _flex.Cols.Count; c++)
            {
                if (_chkGrand.Checked)
                {
                    _flex.Subtotal(AggregateEnum.Sum, 0, -1, c, "Grand Total");
                }
                if (_chkDirection.Checked)
                {
                    _flex.Subtotal(AggregateEnum.Sum, 1, 1, c, "Total for {0}");
                }
                if (_chkRegion.Checked)
                {
                    _flex.Subtotal(AggregateEnum.Sum, 2, 2, c, "Total for {0}");
                }
            }

            // done, autosize columns to finish
            _flex.AutoSizeCols();
        }
Esempio n. 6
0
        void _flex_AfterDataRefresh(object sender, System.ComponentModel.ListChangedEventArgs e)
        {
            _flex.Tree.Style   = TreeStyleFlags.Simple;
            _flex.Tree.Column  = 1;
            _flex.AllowMerging = AllowMergingEnum.Nodes;

            int totalOn = _flex.Cols["Sale Amount"].SafeIndex;

            _flex.Subtotal(AggregateEnum.Sum, 0, 1, totalOn);
            _flex.Subtotal(AggregateEnum.Sum, 1, 2, totalOn);
            _flex.Subtotal(AggregateEnum.Sum, 2, 3, totalOn);
            _flex.AutoSizeCols(1, 1, 1000, 3, 30, AutoSizeFlags.IgnoreHidden);
        }
Esempio n. 7
0
        private void frmSearch4_Load(object sender, System.EventArgs e)
        {
            try
            {
                //vs.AllowEditing  = true;
                vs.AutoSearch    = AutoSearchEnum.FromCursor;
                vs.KeyActionTab  = KeyActionEnum.MoveDown;
                vs.TabIndex      = 0;
                vs.SelectionMode = SelectionModeEnum.Row;

                PublicFunction.L_Init_Label(this);

                vs.Cols.Count = _Cols + 1;
                vs.Rows.Count = _rs.rows + 1;
                for (int c = 1; c < _Cols + 1; c++)
                {
                    vs.Cols[c].Name = _rs.Field(c - 1);
                    if (vs.Cols[c].Name == "SYS_SEL")
                    {
                        vs.Cols[c].Caption  = PublicFunction.L_GetLabel_VS("Public", vs.Cols[c].Name);
                        vs.Cols[c].DataType = typeof(System.Boolean);
                    }
                    else
                    {
                        vs.Cols[c].Caption = PublicFunction.L_GetLabel_VS(_LabelID, vs.Cols[c].Name);
                    }
                    if (c != 8)
                    {
                        vs.Cols[c].AllowEditing = false;
                    }
                }
                for (int r = 0; r < _rs.rows; r++)
                {
                    vs[r + 1, 0] = r + 1;
                    for (int c = 1; c < _Cols + 1; c++)
                    {
                        vs[r + 1, c] = _rs.record(r, c - 1);
                    }
                }
                vs.AutoSizeCols();
//				vs.DoubleClick +=new EventHandler(vs_DoubleClick);
//				vs.KeyDown +=new KeyEventHandler(vs_KeyDown);
//				this.KeyDown+=new KeyEventHandler(vs_KeyDown);
            }
            catch
            {
                MessageBox.Show("Load Form Error");
            }
        }
Esempio n. 8
0
        void fg_AfterDataRefresh(object sender, System.ComponentModel.ListChangedEventArgs e)
        {
            // total on Sale Amount
            int    totalOn = fg.Cols["Sale Amount"].SafeIndex;
            string caption = "Total for {0}";

            // calculate three levels of totals
            fg.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption);
            fg.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption);
            fg.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption);
            fg.Tree.Show(2);

            // autosize the fg to accommodate tree
            fg.AutoSizeCols(1, 1, 1000, 3, 30, AutoSizeFlags.IgnoreHidden);
        }
Esempio n. 9
0
        private void Init_Tree()
        {
            if (vs.Row < 1)
            {
                vs1.Rows.Count = 1;
                return;
            }

            string USER_ID = vs.Rows[vs.Row]["USER_ID"] + "";

            CheckSEC(USER_ID);
            vs1.Styles["Normal"].BackColor       = System.Drawing.Color.WhiteSmoke;
            vs1.Styles["Normal"].Border.Color    = System.Drawing.Color.WhiteSmoke;
            vs1.Styles["EmptyArea"].BackColor    = System.Drawing.Color.WhiteSmoke;
            vs1.Styles["EmptyArea"].Border.Color = System.Drawing.Color.WhiteSmoke;
            vs1.Rows.Count = 1;
            Init_TreeDetail(USER_ID);
            vs1.AutoSizeCols();
        }
Esempio n. 10
0
        private void add(Func.RecordSet rs)
        {
            if (rs.rows <= 0)
            {
                return;
            }
            dwid.Text = wid.Text = "";
            vs.Rows.Count++;
            int row = vs.Rows.Count - 1;

            vs.Rows[row].UserData  = 2;
            vs.Rows[row][0]        = row;
            vs.Rows[row]["EMP_ID"] = rs.record(0, "EMP_ID");
            vs.Rows[row]["EMP_I1"] = rs.record(0, "EMP_I1");
            vs.Rows[row]["EMP_NM"] = rs.record(0, "EMP_NM");
            vs.Rows[row]["CHA_DT"] = DateTime.Parse(dt.Value + "").ToString("yyyy/MM/dd");
            vs.Rows[row]["BLT_NM"] = PublicFunction.A_UserID;
            vs.Rows[row]["BLT_DT"] = T_String.GetDate().ToString("yyyy/MM/dd HH:mm");
            GetOldSalary(row, rs.record(0, "EMP_ID"));
            vs.AutoSizeCols();
        }
Esempio n. 11
0
        void fg_AfterDataRefresh(object sender, System.ComponentModel.ListChangedEventArgs e)
        {
            // total on Sale Amount
            int    totalOn = _flex.Cols["Sale Amount"].SafeIndex;
            string caption = "Total for {0}";

            // don't update the screen while calculating the totals
            _flex.BeginUpdate();

            // calculate three levels of totals
            _flex.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption);
            _flex.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption);
            _flex.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption);
            _flex.Tree.Show(2);

            // auto-size the grid to accommodate the tree
            _flex.AutoSizeCols(1, 1, 1000, 3, 30, AutoSizeFlags.IgnoreHidden);

            // restore screen updates
            _flex.EndUpdate();
        }
Esempio n. 12
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // initialize grid

            // layout
            flex.Rows.Count    = 1;
            flex.Cols.Count    = 2;
            flex.Cols.Fixed    = 0;
            flex.ExtendLastCol = true;
            flex[0, 0]         = "Tag";
            flex[0, 1]         = "Value";

            // styles
            CellStyle cs = flex.Styles.Normal;

            cs.Border.Direction = BorderDirEnum.Vertical;
            cs.TextAlign        = TextAlignEnum.LeftCenter;
            cs.WordWrap         = false;
            cs           = flex.Styles.Add("Data");
            cs.BackColor = SystemColors.Info;
            cs.ForeColor = SystemColors.InfoText;
            cs           = flex.Styles.Add("SourceNode");
            cs.BackColor = Color.Yellow;
            cs.Font      = new Font(flex.Font, FontStyle.Bold);

            // outline tree
            flex.Tree.Column  = 0;
            flex.Tree.Style   = TreeStyleFlags.Simple;
            flex.AllowMerging = AllowMergingEnum.Nodes;

            // other
            flex.AllowResizing = AllowResizingEnum.Columns;
            flex.SelectionMode = SelectionModeEnum.Cell;

            // read XML document into the grid
            PopulateGrid();
            flex.AutoSizeCols();
        }
        private void show()
        {
            double seqMax = 0;

            vs.Visible = false;
            string        sql = "", sql1 = "";
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE06A");
            double max  = T_String.GetMax("MAX(SEQ_N1)", "FILE06A", "LAB_NO=N'" + LAB_NO + "'") - 1;

            for (int i = 1; i < vs1.Rows.Count; i++)
            {
                sql = "Select * from FILE03A where LAB_NO NOT LIKE 'HDTV%'AND LAB_NO NOT LIKE 'TTTV%' and EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "'"
                      + " AND LAB_ST>=(SELECT CONVERT(NVARCHAR,INH_DT,111) FROM FILB01A WHERE EMP_ID='" + vs1.Rows[i]["EMP_ID"] + "')"
                      + " AND LAB_ST<'" + DateTime.Parse(dt).ToString("yyyy/MM/dd") + "'"
                      + " AND (ISNULL(LIM_NO,0)=1 OR (ISNULL(LIM_NO,0)=0 AND LAB_ED>'" + DateTime.Parse(dt).ToString("yyyy/MM/dd") + "'))"
                      + " ORDER BY LAB_ST DESC";
                Func.RecordSet rslb = new Func.RecordSet(sql, con);
                sql1 = "Select top 1 * from FILE06A where EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "' ORDER BY LA1_SG DESC";
                Func.RecordSet rslb1 = new Func.RecordSet(sql1, con);
                if (rslb.rows > 0)
                {
                    seqMax = T_String.GetMax("MAX(SEQ_NO)", "FILE06A", "emp_id=N'" + vs1.Rows[i]["EMP_ID"] + "'");
                    nav.ToolBar_Click(new ToolBarButtonClickEventArgs(nav.cmd_add));
                    vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                    vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = rslb.record(0, "LAB_ID");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = rslb.record(0, "LAB_ST");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = rslb.record(0, "LAB_ED");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = dt;
                    vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = dt1;
                    if (PublicFunction.CUS_ID == "43")                 //cty ASTRO
                    {
                        if (rslb1.rows == 0)
                        {
                            vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = Convert.ToDateTime(rslb.record(0, "LAB_ST")).AddYears(2);
                            vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = Convert.ToDateTime(rslb.record(0, "LAB_ST")).AddYears(2);
                        }
                        if (rslb1.rows > 0)
                        {
                            vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = Convert.ToDateTime(rslb1.record(0, "LA1_ST")).AddYears(1);
                            vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = Convert.ToDateTime(rslb1.record(0, "LA1_ST")).AddYears(1);
                        }
                    }
                    vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = LAB_NO;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = seqMax;
                    maxx++;
                    vs.Rows[vs.Rows.Count - 1][0] = vs.Rows.Count - 1;
                    for (int c = 1; c < vs1.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1][vs1.Cols[c].Name] = vs1.Rows[i][c];
                    }
                    for (int c = 1; c < vs2.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1]["SAL_N" + c] = vs2.Cols[c].Name;
                        vs.Rows[vs.Rows.Count - 1]["SAL_Q" + c] = vs2.Rows[1][c];
                    }

                    // LAB_ID
                    Func.RecordSet rs1 = new Func.RecordSet("Select * from FILE05A where LAB_NO=N'" + LAB_NO + "'", con);
                    if (rs1.rows > 0)
                    {
                        string LAB_ID = T_String.GetDataFromSQL("LAB_ID", "FILE05A", "LAB_NO=N'" + LAB_NO + "'");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_ID"] + "");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_I1"] + "");
                        if (LAB_ID.IndexOf("@") >= 0)
                        {
                            double vl = max + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                            vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                            string st = "000000000000";
                            max    = vl;
                            st     = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                            LAB_ID = LAB_ID.Replace("@", vl.ToString(st));
                        }
                        //THEM CHUC NANG GIONG BEN HDLD
                        DateTime ngayky = DateTime.Parse(dt);
                        if (PublicFunction.CUS_ID == "44")                       //Leeshin
                        {
                            LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yy") + "");
                        }
                        else
                        {
                            LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                        }
                        LAB_ID = LAB_ID.Replace("*(Month)", ngayky.ToString("MM") + "");
                        LAB_ID = LAB_ID.Replace("*(Day)", ngayky.ToString("dd") + "");
                        //lay so lan ki
                        int count = 0;
                        if (PublicFunction.CUS_ID == "44")                       //Leeshin lay so lan ki theo loai hop dong
                        {
                            count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE06A", "EMP_ID=N'" + vs1.Rows[i]["EMP_ID"]
                                                                               + "' AND LAB_NO ='" + LAB_NO + "' and LA1_ST>=(SELECT CONVERT(NVARCHAR,INH_DT,111) INH_DT FROM FILB01A "
                                                                               + " WHERE EMP_ID='" + vs1.Rows[i]["EMP_ID"] + "')"));
                        }
                        else
                        {
                            count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE06A", "EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "'"));
                        }
                        LAB_ID = LAB_ID.Replace("*(Count)", (count + 1) + "");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ID"] = LAB_ID;
                    }


                    lb.Text   = ((int)(i * 100) / vs1.Rows.Count) + "% - " + vs1.Rows[i]["EMP_NM"];
                    pro.Value = (int)(i * 100) / vs1.Rows.Count;
                }
            }
            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
Esempio n. 14
0
        private void Init()
        {
            // initialize child flex control control
            _flex = new C1.Win.C1FlexGrid.C1FlexGrid();
            ((System.ComponentModel.ISupportInitialize)(this._flex)).BeginInit();
            _flex.Dock          = DockStyle.Fill;
            _flex.BorderStyle   = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle;
            _flex.SelectionMode = SelectionModeEnum.Row;
            _flex.FocusRect     = FocusRectEnum.None;
            _flex.AllowEditing  = false;
            _flex.AutoSearch    = AutoSearchEnum.FromCursor;
            _flex.Rows.Count    = rs.rows + 1;
            _flex.Cols.Fixed    = 0;
            _flex.KeyActionTab  = KeyActionEnum.MoveDown;
            _flex.TabIndex      = 0;
            _flex.Font          = _ctl.Font;
            _flex.Styles        = _ctl.Styles;
            ((System.ComponentModel.ISupportInitialize)(this._flex)).EndInit();
            _flex.Cols.Count = _cols;
            for (int c = 0; c < _cols; c++)
            {
                _flex.Cols[c].Name    = rs.Field(c);
                _flex.Cols[c].Caption = Function.PublicFunction.L_GetLabel_VS(LabelID, _flex.Cols[c].Name);
            }

            // populate child flex control control
            for (int r = 0; r < rs.rows; r++)
            {
                for (int c = 0; c < _cols; c++)
                {
                    _flex[r + 1, c] = rs.record(r, c);
                }
            }

            // initialize selection
            _flex.Row = -1;
            string s = _ctl.GetDataDisplay(_row, _col);

            for (int r = 1; r < _flex.Rows.Count && _flex.Row < 0; r++)
            {
                if (_flex.GetDataDisplay(r, 0) == s)
                {
                    _flex.Row = r;
                }
            }

            // initialize form
            Controls.Add(_flex);
            FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            StartPosition   = FormStartPosition.Manual;

            //SystemInformation.MaxWindowTrackSize.IsEmpty ;
            //MessageBox.Show(""+SystemInformation.MaxWindowTrackSize.Height);
            //MessageBox.Show(""+System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height);


            // set form size
            _flex.AutoSizeCols(4);
            int rows = Math.Min(10, _flex.Rows.Count);
            int cols = _flex.Cols.Count;
            int wid  = _flex.Cols[cols - 1].Right + 2;
            int hei  = rows * _flex.Rows.DefaultSize + 2;

            if (rows < _flex.Rows.Count)
            {
                wid += SystemInformation.VerticalScrollBarWidth;
            }
            ClientSize = new Size(wid, hei);

            int ww = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            int hh = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            int x, y;

            // set form location
            Rectangle rc = _ctl.GetCellRect(_row, _col, true);

            rc = _ctl.RectangleToScreen(rc);
            if ((rc.Left + wid) < ww - 50)
            {
                x = rc.Left;
            }
            else
            {
                x = rc.Right - wid;
            }

            if ((rc.Bottom + hei) < hh - 50)
            {
                y = rc.Bottom;
            }
            else
            {
                y = rc.Top - hei;
            }

            Location = new Point(x, y);



            // initialize event handlers
            Deactivate    += new System.EventHandler(_flex_Click);
            _flex.Click   += new System.EventHandler(_flex_Click);
            _flex.KeyDown += new System.Windows.Forms.KeyEventHandler(_flex_KeyDown);
        }
Esempio n. 15
0
        private void show()
        {
            DateTime dt5;
            double   seqMax = 0;

            vs.Visible = false;
            string        sql = "";
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE06A");
            double max  = T_String.GetMax("MAX(SEQ_N1)", "FILE06A", "LAB_NO=N'" + LAB_NO + "'") - 1;

            DateTime dt6 = T_String.GetDate();

            dt6 = dt6.AddDays(T_String.IsNullTo0(day));
            for (int i = 1; i < vs1.Rows.Count; i++)
            {
                sql = "Select * from FILE03A where EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "' ORDER BY SEQ_NO DESC";
                Func.RecordSet rslb = new Func.RecordSet(sql, con);
                sql = "Select * from FILE06A where EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "' ORDER BY SEQ_NO DESC";
                Func.RecordSet rse       = new Func.RecordSet(sql, con);
                DateTime       dtHienTai = T_String.GetDate();
                DateTime       dtKT      = T_String.GetDate();
                dtKT = Convert.ToDateTime(rslb.record(0, "LAB_ST"));
//					if((ck411==false && rslb.record(0,"LAB_NO") =="HDVTH" && rslb.rows>=1 && rse.rows>=0 && Convert.ToDateTime(rse.record(0,"LA1_ST"))<=dt6))
                if ((ck411 == false && rslb.rows >= 1 && rse.rows == 0 && rslb.record(0, "LAB_NO") == "HDVTH" && dtKT.AddYears(1) <= dt6) || (ck411 == false && rslb.rows >= 1 && rse.rows > 0 && Convert.ToDateTime(rse.record(0, "LA1_ED")) <= dt6))
                {
                    seqMax = T_String.GetMax("MAX(SEQ_NO)", "FILE06A", "EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "'");
                    nav.ToolBar_Click(new ToolBarButtonClickEventArgs(nav.cmd_add));
                    vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                    vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = rslb.record(0, "LAB_ID");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = rslb.record(0, "LAB_ST");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = rslb.record(0, "LAB_ED");
                    dt5 = Convert.ToDateTime(rslb.record(0, "LAB_ST"));
                    vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = dt5.AddYears(1).ToString("yyyy/MM/dd");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = dt5.AddYears(2).ToString("yyyy/MM/dd");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ED"]).AddDays(-1).ToString("yyyy/MM/dd");

                    if (rse.rows > 0)
                    {
                        vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = rse.record(0, "LA1_ED");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ST"]).AddYears(1).ToString("yyyy/MM/dd");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ST"]).AddDays(1).ToString("yyyy/MM/dd");
                    }

                    vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = dt1;
                    vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = LAB_NO;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = seqMax;
                    maxx++;
                    vs.Rows[vs.Rows.Count - 1][0] = vs.Rows.Count - 1;
                    for (int c = 1; c < vs1.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1][vs1.Cols[c].Name] = vs1.Rows[i][c];
                    }
                    for (int c = 1; c < vs2.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1]["SAL_N" + c] = vs2.Cols[c].Name;
                        vs.Rows[vs.Rows.Count - 1]["SAL_Q" + c] = vs2.Rows[1][c];
                    }
                    // LAB_ID
                    Func.RecordSet rs1 = new Func.RecordSet("Select * from FILE05A where LAB_NO=N'" + LAB_NO + "'", con);
                    if (rs1.rows > 0)
                    {
                        string LAB_ID = T_String.GetDataFromSQL("LAB_ID", "FILE05A", "LAB_NO=N'" + LAB_NO + "'");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_ID"] + "");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_I1"] + "");
                        if (LAB_ID.IndexOf("@") >= 0)
                        {
                            double vl = max + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                            vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                            string st = "000000000000";
                            max    = vl;
                            st     = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                            LAB_ID = LAB_ID.Replace("@", vl.ToString(st));
                        }
                        DateTime ngayky = DateTime.Parse(vs.Rows[vs.Rows.Count - 1]["LA1_ST"] + "");
                        LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ID"] = LAB_ID;

                        vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                        maxx++;
                    }
                    lb.Text   = ((int)(i * 100) / vs1.Rows.Count) + "% - " + vs1.Rows[i]["EMP_NM"];
                    pro.Value = (int)(i * 100) / vs1.Rows.Count;
                }
                //if(ck411==true && rslb.rows>=1 && Convert.ToDateTime(dt)<=dt6)
                if (ck411 == true && rslb.rows >= 1)
                {
                    seqMax = T_String.GetMax("MAX(SEQ_NO)", "FILE06A", "emp_id=N'" + vs1.Rows[i]["EMP_ID"] + "'");
                    nav.ToolBar_Click(new ToolBarButtonClickEventArgs(nav.cmd_add));
                    vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                    vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = rslb.record(0, "LAB_ID");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = rslb.record(0, "LAB_ST");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = rslb.record(0, "LAB_ED");
                    dt5 = Convert.ToDateTime(rslb.record(0, "LAB_ST"));
//						vs.Rows[vs.Rows.Count-1]["LA1_ST"]=dt5.AddYears(1).ToString("yyyy/MM/dd");
//						vs.Rows[vs.Rows.Count-1]["LA1_ED"]=dt5.AddYears(2).ToString("yyyy/MM/dd");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = dt;
                    vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ST"]).AddYears(1).ToString("yyyy/MM/dd");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ED"] = Convert.ToDateTime(vs.Rows[vs.Rows.Count - 1]["LA1_ED"]).AddDays(-1).ToString("yyyy/MM/dd");
//						if(rse.rows==0 && rslb.record(0,"LAB_NO")!="HDVTH")
//						{
//							vs.Rows[vs.Rows.Count-1]["LA1_ED"]=Convert.ToDateTime(vs.Rows[vs.Rows.Count-1]["LAB_ED"]).AddDays(+1).ToString("yyyy/MM/dd");
//						}
//						vs.Rows[vs.Rows.Count-1]["LA1_ED"]=Convert.ToDateTime(vs.Rows[vs.Rows.Count-1]["LA1_ED"]).AddDays(-1).ToString("yyyy/MM/dd");
//
//						vs.Rows[vs.Rows.Count-1]["LA1_ST"]=dt;
//
//						if(rse.rows>0)
//						{
//							vs.Rows[vs.Rows.Count-1]["LA1_ST"]=rse.record(0,"LA1_ED");
//							vs.Rows[vs.Rows.Count-1]["LA1_ED"]=Convert.ToDateTime(vs.Rows[vs.Rows.Count-1]["LA1_ST"]).AddYears(0).ToString("yyyy/MM/dd");
//							vs.Rows[vs.Rows.Count-1]["LA1_ST"]=dt;
//						}

                    vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = dt1;
                    vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = LAB_NO;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = seqMax;
                    maxx++;
                    vs.Rows[vs.Rows.Count - 1][0] = vs.Rows.Count - 1;
                    for (int c = 1; c < vs1.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1][vs1.Cols[c].Name] = vs1.Rows[i][c];
                    }
                    for (int c = 1; c < vs2.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1]["SAL_N" + c] = vs2.Cols[c].Name;
                        vs.Rows[vs.Rows.Count - 1]["SAL_Q" + c] = vs2.Rows[1][c];
                    }
                    Func.RecordSet rs1 = new Func.RecordSet("Select * from FILE05A where LAB_NO=N'" + LAB_NO + "'", con);
                    if (rs1.rows > 0)
                    {
                        string LAB_ID = T_String.GetDataFromSQL("LAB_ID", "FILE05A", "LAB_NO=N'" + LAB_NO + "'");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_ID"] + "");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_I1"] + "");
                        if (LAB_ID.IndexOf("@") >= 0)
                        {
                            double vl = max + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                            vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                            string st = "000000000000";
                            max    = vl;
                            st     = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                            LAB_ID = LAB_ID.Replace("@", vl.ToString(st));
                        }
                        DateTime ngayky = DateTime.Parse(vs.Rows[vs.Rows.Count - 1]["LAB_ST"] + "");
                        LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                        vs.Rows[vs.Rows.Count - 1]["LA1_ID"] = LAB_ID;

                        vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                        maxx++;
                    }
                    lb.Text   = ((int)(i * 100) / vs1.Rows.Count) + "% - " + vs1.Rows[i]["EMP_NM"];
                    pro.Value = (int)(i * 100) / vs1.Rows.Count;
                }
            }

            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
Esempio n. 16
0
        private void show()
        {
            vs.Visible = false;
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            string sql = "";

            sql = "Select * from FILE01A";
            Func.RecordSet rs2 = new Func.RecordSet(sql, con);
            ArrayList      a   = new ArrayList();
            ArrayList      b   = new ArrayList();

            for (int i = 0; i < rs2.rows; i++)
            {
                a.Add(rs2.record(i, "LAB_NO"));
                int tam = T_String.IsNullTo0(T_String.GetDataFromSQL("MAX(SEQ_N1)", "FILE03A", "LAB_NO=N'" + rs2.record(i, "LAB_NO") + "'"));
                if (tam == 1)
                {
                    tam = T_String.IsNullTo0(rs2.record(i, "STT_N2") + "");
                }
                b.Add(tam);
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE03A");

            sql = "Select EMP_ID,EMP_I1,EMP_NM,INH_DT,TYP_ID,POS_ID,DEP_ID from FILB01A where (VAC_BT is null or VAC_BT=0)";
            if (NEW_BT)
            {
                sql = sql + " and isnull(NEW_BT,0)=1 and isnull(LCK_BT,0)=0";
            }
            if (wh != "")
            {
                sql += " and " + wh;
            }
            DateTime dt1 = T_String.GetDate();

            dt1  = dt1.AddDays(T_String.IsNullTo0(day));
            sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                   + "' or LIM_NO=1)";
            vs.Rows.Count = 1;
            Func.RecordSet rs = new Func.RecordSet(sql, con);
            for (int i = 0; i < rs.rows; i++)
            {
                try
                {
                    sql = "Select * from FILE03A where EMP_ID=N'" + rs.record(i, "EMP_ID") + "' ORDER BY LAB_ST DESC";
                    Func.RecordSet rslb = new Func.RecordSet(sql, con);
                    DateTime       dt;
                    int            max;
                    if (rslb.rows == 0)
                    {
                        dt  = DateTime.Parse(rs.record(i, "INH_DT"));
                        max = 1;
                    }
                    else
                    {
                        dt = DateTime.Parse(rslb.record(0, "LAB_ED"));
                        //dt=dt.AddDays(1);
                        max = 1 + T_String.IsNullTo0(rslb.record(0, "SEQ_NO"));
                    }
//					if(ngaytinh>0)//ngaytinh
//					{
//						if(dt.Day<ngaytinh)
//							dt=new DateTime (dt.Year,dt.Month,1);
//						else
//						{
//							dt=dt.AddMonths(1);
//							dt=new DateTime (dt.Year,dt.Month,1);
//						}
//					}
                    if (LAB_N1 != "")
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and a.LAB_NO=N'" + LAB_N1 + "' and a.LAB_NO=b.LAB_NO";
                    }
                    else
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and SEQ_NO=" + max + " and a.LAB_NO=b.LAB_NO";
                    }
                    Func.RecordSet rs1 = new Func.RecordSet(sql, con);
                    if (rs1.rows == 0)
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and REP_BT=1 and a.LAB_NO=b.LAB_NO";
                        rs1 = new Func.RecordSet(sql, con);
                    }
                    try
                    {
                        if (rs1.rows > 0 && rs1.record(0, "LAB_ID") + "" != "" && (this.LAB_NO == "" || this.LAB_NO == rs1.record(0, "LAB_NO")))
                        {
                            vs.Rows.Count++;
                            vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                            vs.Rows[vs.Rows.Count - 1][0]        = vs.Rows.Count - 1;
                            vs.Rows[vs.Rows.Count - 1]["EMP_ID"] = rs.record(i, "EMP_ID");
                            vs.Rows[vs.Rows.Count - 1]["EMP_I1"] = rs.record(i, "EMP_I1");
                            vs.Rows[vs.Rows.Count - 1]["EMP_NM"] = rs.record(i, "EMP_NM");
                            vs.Rows[vs.Rows.Count - 1]["TYP_ID"] = rs.record(i, "TYP_ID");
                            vs.Rows[vs.Rows.Count - 1]["POS_ID"] = rs.record(i, "POS_ID");
                            vs.Rows[vs.Rows.Count - 1]["DEP_ID"] = rs.record(i, "DEP_ID");
                            vs.Rows[vs.Rows.Count - 1]["INH_DT"] = rs.record(i, "INH_DT");
                            vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = rs1.record(0, "SEQ_NO");
                            if (date != "")
                            {
                                vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = date;
                                dt = DateTime.Parse(date);
                            }
                            else
                            {
                                vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = dt.ToString("yyyy/MM/dd");
                            }

                            if (rs1.record(0, "LIM_NO") + "" == "True")
                            {
                                vs.Rows[vs.Rows.Count - 1]["LIM_NO"] = "True";
                            }
                            else
                            {
                                if (rs1.record(0, "YYY_YY") + "" != "")
                                {
                                    dt = dt.AddYears(T_String.IsNullTo0(rs1.record(0, "YYY_YY") + ""));
                                }
                                else
                                {
                                    dt = dt.AddMonths(T_String.IsNullTo0(rs1.record(0, "MMM_MM") + ""));
                                }
                                if (ngaytinh > 0)                             //ngaytinh
                                {
                                    if (dt.Day < ngaytinh)
                                    {
                                        dt = new DateTime(dt.Year, dt.Month, 1);
                                    }
                                    else
                                    {
                                        dt = dt.AddMonths(1);
                                        dt = new DateTime(dt.Year, dt.Month, 1);
                                    }
                                }
                                if (ngaytru)
                                {
                                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.AddDays(-1).ToString("yyyy/MM/dd");
                                }
                                else
                                {
                                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.ToString("yyyy/MM/dd");
                                }
                            }
                            vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = rs1.record(0, "LAB_NO");
                            vs.Rows[vs.Rows.Count - 1]["LAB_TP"] = rs1.record(0, "LAB_TP");
                            // LAB_ID  ma so hop dong
                            string LAB_ID = rs1.record(0, "LAB_ID");
                            LAB_ID = LAB_ID.Replace("#", rs.record(i, "EMP_ID") + "");
                            LAB_ID = LAB_ID.Replace("&", rs.record(i, "EMP_I1") + "");
                            if (LAB_ID.IndexOf("@") >= 0)
                            {
                                int index = a.IndexOf(rs1.record(0, "LAB_NO"));
                                int vl    = T_String.IsNullTo0(b[index] + "") + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                                vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                                string st = "000000000000";
                                b[index] = vl;
                                st       = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                                LAB_ID   = LAB_ID.Replace("@", vl.ToString(st));
                            }

                            DateTime ngayky = DateTime.Parse(vs.Rows[vs.Rows.Count - 1]["LAB_ST"] + "");
                            LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                            LAB_ID = LAB_ID.Replace("*(Month)", ngayky.ToString("MM") + "");
                            LAB_ID = LAB_ID.Replace("*(Day)", ngayky.ToString("dd") + "");

                            int count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE03A", "EMP_ID=N'" + rs.record(i, "EMP_ID") + "'"));
                            LAB_ID = LAB_ID.Replace("*(Count)", (count + 1) + "");
                            LAB_ID = LAB_ID.Replace("*(DEP)", rs.record(i, "DEP_ID") + "");
                            LAB_ID = LAB_ID.Replace("*(POS)", rs.record(i, "POS_ID") + "");
                            LAB_ID = LAB_ID.Replace("*(NATURE)", rs.record(i, "TYP_ID") + "");



                            ////////////
                            vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = LAB_ID;

                            vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                            maxx++;
                        }
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message); vs.Rows.Count--; }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                lb.Text   = ((int)(i * 100) / rs.rows) + "% - " + rs.record(i, "EMP_NM");
                pro.Value = (int)(i * 100) / rs.rows;
            }
            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
Esempio n. 17
0
        private void show()
        {
            vs.Visible = false;
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            string sql = "";

            sql = "Select * from FILE01A ";
            Func.RecordSet rs2 = new Func.RecordSet(sql, con);
            ArrayList      a   = new ArrayList();
            ArrayList      b   = new ArrayList();

            for (int i = 0; i < rs2.rows; i++)
            {
                a.Add(rs2.record(i, "LAB_NO"));
                int tam = T_String.IsNullTo0(T_String.GetDataFromSQL("MAX(SEQ_N1)", "FILE03A", "LAB_NO=N'" + rs2.record(i, "LAB_NO") + "'"));
                if (tam == 1)
                {
                    tam = T_String.IsNullTo0(rs2.record(i, "STT_N2") + "");
                }
                b.Add(tam);
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE03A");

            sql = "Select EMP_ID,EMP_I1,EMP_NM,INH_DT,TYP_ID,POS_ID,DEP_ID from FILB01A where (VAC_BT is null or VAC_BT=0)";
            if (NEW_BT)
            {
                sql = sql + " and isnull(NEW_BT,0)=1 and isnull(LCK_BT,0)=0";
            }
            if (wh != "")
            {
                sql += " and " + wh;
            }
            DateTime dt1 = T_String.GetDate();

            dt1 = dt1.AddDays(T_String.IsNullTo0(day));
            DateTime NgayBD     = T_String.GetDate();
            DateTime NgayVaoLam = T_String.GetDate();

            //-------------------
            if (PublicFunction.CUS_ID == "43")         //cty ASTRO
            {
                SqlConnection con1 = new SqlConnection(PublicFunction.C_con.ConnectionString);
                if (con1.State == ConnectionState.Closed)
                {
                    con1.Open();
                }
                string sql1 = "";
                sql1 = "Select * from FILB01A";
                if (wh != "")
                {
                    sql1 += " where " + wh;
                }
                Func.RecordSet rs3 = new Func.RecordSet(sql1, con1);
                if (rs3.rows > 0)
                {
                    NgayVaoLam = DateTime.Parse(rs3.record(0, "INH_DT"));
                }
                if (NgayVaoLam.Day >= 1 & NgayVaoLam.Day <= 20)
                {
                    NgayBD = new DateTime(NgayVaoLam.Year, NgayVaoLam.Month, 1);
                    NgayBD = NgayBD.AddMonths(1);
                }
                if (NgayVaoLam.Day >= 21 & NgayVaoLam.Day <= 31)
                {
                    NgayBD = new DateTime(NgayVaoLam.Year, NgayVaoLam.Month, 1);
                    NgayBD = NgayBD.AddMonths(2);
                }
                sql += " and '" + dt1.ToString("yyyy/MM/dd") + "'>='" + NgayBD.ToString("yyyy/MM/dd") + "' and EMP_ID not in(Select Distinct EMP_ID from FILE03A where LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                       + "' or LIM_NO=1)";
            }
            //-------------------
            ////luan rem de khi in roi van hien ra
            if (PublicFunction.CUS_ID != "43")
            {
                if (PublicFunction.CUS_ID == "44")               //LeeShin ki lai tu dau cho nguoi di lam lai
                {
                    sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where (LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                           + "' and LAB_ST>=(SELECT CONVERT(NVARCHAR,INH_DT,111) FROM FILB01A WHERE FILB01A.EMP_ID=FILE03A.EMP_ID)) "
                           + "or ( LIM_NO=1 and LAB_ST>=(SELECT CONVERT(NVARCHAR,INH_DT,111) FROM FILB01A WHERE FILB01A.EMP_ID=FILE03A.EMP_ID) ))";
                }
                else if (PublicFunction.CUS_ID == "52")               //domex quang nam, in HDLD lan dau cung thoi diem voi HDTV
                {
                    sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where (LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                           + "' and LAB_NO NOT LIKE 'HDTV%') or LIM_NO=1)";
                }
                else if (PublicFunction.CUS_ID == "53")               // Omexey, ko ki HD cho nv TQ và Cam
                {
                    sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                           + "' or LIM_NO=1) and COU_ID<>'6' and COU_ID<>'10' and COU_ID<>'12'";
                }
                else
                {
                    sql += " and EMP_ID not in(Select Distinct EMP_ID from FILE03A where LAB_ED>'" + dt1.ToString("yyyy/MM/dd")
                           + "' or LIM_NO=1)";
                }
            }
            vs.Rows.Count = 1;
            Func.RecordSet rs = new Func.RecordSet(sql, con);
            for (int i = 0; i < rs.rows; i++)
            {
                try
                {
                    sql = "Select * from FILE03A where EMP_ID=N'" + rs.record(i, "EMP_ID") + "' ORDER BY LAB_ST DESC,LAB_ED DESC";
                    if (PublicFunction.CUS_ID == "44")                 //LeeShin
                    {
                        sql = "Select FILE03A.* from FILE03A INNER JOIN FILB01A ON FILE03A.EMP_ID=FILB01A.EMP_ID where FILE03A.EMP_ID=N'" + rs.record(i, "EMP_ID")
                              + "' AND LAB_ST>=INH_DT ORDER BY LAB_ST DESC";
                    }
                    Func.RecordSet rslb = new Func.RecordSet(sql, con);
                    DateTime       dt;
                    int            max;
                    if (rslb.rows == 0)
                    {
                        dt = DateTime.Parse(rs.record(i, "INH_DT"));
                        if (PublicFunction.CUS_ID == "43")                     //cty ASTRO
                        {
                            dt = NgayBD;
                        }
                        max = 1;
                    }
                    else
                    {
                        dt = DateTime.Parse(rslb.record(0, "LAB_ED"));
                        dt = dt.AddDays(1);
                        if (PublicFunction.CUS_ID == "44" || PublicFunction.CUS_ID == "53")                   //LEESHIN LAY NGAY BD KI HD SAU KHI THU VIEC LA NGAY 1 TAY
                        {
                            if (rslb.record(0, "LAB_NO") == "HDTV1" || rslb.record(0, "LAB_NO") == "HDTV2" || rslb.record(0, "LAB_NO") == "HDTV")
                            {
                                dt = DateTime.Parse(rslb.record(0, "LAB_ED"));
                                if (dt.Day > 15)
                                {
                                    dt = dt.AddMonths(1);
                                }
                                dt = DateTime.Parse(dt.ToString("yyyy/MM") + "/01");
                            }
                        }
                        if (PublicFunction.CUS_ID == "52")                     //Domex Quang Nam
                        {
                            if (rslb.record(0, "LAB_NO") == "HDTV2" || rslb.record(0, "LAB_NO") == "HDTV1" || rslb.record(0, "LAB_NO") == "HDTV6")
                            {
                                dt = DateTime.Parse(rslb.record(0, "LAB_ST"));
                            }
                        }
                        max = 1 + T_String.IsNullTo0(rslb.record(0, "SEQ_NO"));
                    }
//					if(ngaytinh>0)//ngaytinh
//					{
//						if(dt.Day<ngaytinh)
//							dt=new DateTime (dt.Year,dt.Month,1);
//						else
//						{
//							dt=dt.AddMonths(1);
//							dt=new DateTime (dt.Year,dt.Month,1);
//						}
//					}
                    if (LAB_N1 != "")
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and a.LAB_NO=N'" + LAB_N1 + "' and a.LAB_NO=b.LAB_NO";
                    }
                    else
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and SEQ_NO=" + max + " and a.LAB_NO=b.LAB_NO";
                    }
                    Func.RecordSet rs1 = new Func.RecordSet(sql, con);
                    if (rs1.rows == 0)
                    {
                        sql = "Select * from FILE02A a, FILE01A b where TYP_ID=N'"
                              + rs.record(i, "TYP_ID") + "' and REP_BT=1 and a.LAB_NO=b.LAB_NO";
                        rs1 = new Func.RecordSet(sql, con);
                    }
                    try
                    {
                        if (rs1.rows > 0 && rs1.record(0, "LAB_ID") + "" != "" && (this.LAB_NO == "" || this.LAB_NO == rs1.record(0, "LAB_NO")))
                        {
                            vs.Rows.Count++;
                            vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                            vs.Rows[vs.Rows.Count - 1][0]        = vs.Rows.Count - 1;
                            vs.Rows[vs.Rows.Count - 1]["EMP_ID"] = rs.record(i, "EMP_ID");
                            vs.Rows[vs.Rows.Count - 1]["EMP_I1"] = rs.record(i, "EMP_I1");
                            vs.Rows[vs.Rows.Count - 1]["EMP_NM"] = rs.record(i, "EMP_NM");
                            vs.Rows[vs.Rows.Count - 1]["TYP_ID"] = rs.record(i, "TYP_ID");
                            vs.Rows[vs.Rows.Count - 1]["POS_ID"] = rs.record(i, "POS_ID");
                            vs.Rows[vs.Rows.Count - 1]["DEP_ID"] = rs.record(i, "DEP_ID");
                            vs.Rows[vs.Rows.Count - 1]["INH_DT"] = rs.record(i, "INH_DT");
                            vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = rs1.record(0, "SEQ_NO");
                            if (date != "")
                            {
                                vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = date;
                                dt = DateTime.Parse(date);
                            }
                            else
                            {
                                vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = dt.ToString("yyyy/MM/dd");
                            }

                            if (rs1.record(0, "LIM_NO") + "" == "True")
                            {
                                vs.Rows[vs.Rows.Count - 1]["LIM_NO"] = "True";
                            }
                            else
                            {
                                if (PublicFunction.CUS_ID == "22" && rs1.record(0, "LAB_NO") == "HDHV")                           //xet TH HDTV 6 ngay cho DM
                                {
                                    //dt=DateTime.Parse(rslb.record(0,"LAB_ST"));
                                    int id = 0;
                                    while (id < 27)
                                    {
//										string data=T_String.GetDataFromSQL("h"+dt.Day,"FILA16A","YYY_YY="+dt.Year+" and MMM_MM="+dt.Month);
//										if(dt.DayOfWeek!=DayOfWeek.Sunday && (data+""=="False" || data==null ))
//										{
//											id++;
//
//										}
                                        id++;
                                        dt = dt.AddDays(1);
                                    }
                                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.ToString("yyyy/MM/dd");
                                }
                                else
                                {
                                    if (rs1.record(0, "YYY_YY") + "" != "")
                                    {
                                        dt = dt.AddYears(T_String.IsNullTo0(rs1.record(0, "YYY_YY") + ""));
                                    }
                                    else
                                    {
                                        dt = dt.AddMonths(T_String.IsNullTo0(rs1.record(0, "MMM_MM") + ""));
                                    }
                                    if (ngaytinh > 0)                                 //ngaytinh
                                    {
                                        if (dt.Day < ngaytinh)
                                        {
                                            dt = new DateTime(dt.Year, dt.Month, 1);
                                        }
                                        else
                                        {
                                            dt = dt.AddMonths(1);
                                            dt = new DateTime(dt.Year, dt.Month, 1);
                                        }
                                    }
                                    if (ngaytru)
                                    {
                                        vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.AddDays(-1).ToString("yyyy/MM/dd");
                                    }
                                    else
                                    {
                                        vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.ToString("yyyy/MM/dd");
                                    }
                                    if (PublicFunction.CUS_ID == "43")
                                    {
                                        vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = dt.AddDays(-1).ToString("yyyy/MM/dd");
                                    }
                                }
                            }
                            vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = rs1.record(0, "LAB_NO");
                            vs.Rows[vs.Rows.Count - 1]["LAB_TP"] = rs1.record(0, "LAB_TP");
                            // LAB_ID  ma so hop dong
                            string LAB_ID = rs1.record(0, "LAB_ID");
                            LAB_ID = LAB_ID.Replace("#", rs.record(i, "EMP_ID") + "");
                            LAB_ID = LAB_ID.Replace("&", rs.record(i, "EMP_I1") + "");
                            if (LAB_ID.IndexOf("@") >= 0)
                            {
                                int index = a.IndexOf(rs1.record(0, "LAB_NO"));
                                int vl    = T_String.IsNullTo0(b[index] + "") + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                                vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                                string st = "000000000000";
                                b[index] = vl;
                                st       = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                                LAB_ID   = LAB_ID.Replace("@", vl.ToString(st));
                            }

                            DateTime ngayky = DateTime.Parse(vs.Rows[vs.Rows.Count - 1]["LAB_ST"] + "");
                            if (PublicFunction.CUS_ID == "44")                           //Leeshin
                            {
                                LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yy") + "");
                            }
                            else
                            {
                                LAB_ID = LAB_ID.Replace("*(Year)", ngayky.ToString("yyyy") + "");
                            }
                            LAB_ID = LAB_ID.Replace("*(Month)", ngayky.ToString("MM") + "");
                            LAB_ID = LAB_ID.Replace("*(Day)", ngayky.ToString("dd") + "");
                            //lay so lan ki
                            int count = 0;
                            if (PublicFunction.CUS_ID == "44")                           //Leeshin lay so lan ki theo loai hop dong
                            {
                                if (rs1.record(0, "LAB_NO") == "HDTV1" || rs1.record(0, "LAB_NO") == "HDTV2")
                                {
                                    count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE03A", "EMP_ID=N'" + rs.record(i, "EMP_ID") + "' AND LAB_NO like 'HDTV%'"));
                                }
                                else
                                {
                                    count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE03A", "EMP_ID=N'" + rs.record(i, "EMP_ID") + "' AND LAB_NO<>'HDTV'"));
                                }
                            }
                            else
                            {
                                count = T_String.IsNullTo0(T_String.GetDataFromSQL("Count(*)", "FILE03A", "EMP_ID=N'" + rs.record(i, "EMP_ID") + "'"));
                            }
                            LAB_ID = LAB_ID.Replace("*(Count)", (count + 1) + "");
                            LAB_ID = LAB_ID.Replace("*(DEP)", rs.record(i, "DEP_ID") + "");
                            LAB_ID = LAB_ID.Replace("*(POS)", rs.record(i, "POS_ID") + "");
                            LAB_ID = LAB_ID.Replace("*(NATURE)", rs.record(i, "TYP_ID") + "");



                            ////////////
                            vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = LAB_ID;

                            vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                            maxx++;
                        }
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message); vs.Rows.Count--; }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                lb.Text   = ((int)(i * 100) / rs.rows) + "% - " + rs.record(i, "EMP_NM");
                pro.Value = (int)(i * 100) / rs.rows;
            }
            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
Esempio n. 18
0
        private void show()
        {
            double seqMax = 0;

            vs.Visible = false;
            string        sql = "";
            SqlConnection con = new SqlConnection(PublicFunction.C_con.ConnectionString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            double maxx = T_String.GetMax("MAX(SEQ_N2)", "FILE06A");
            double max  = T_String.GetMax("MAX(SEQ_N1)", "FILE06A", "LAB_NO=N'" + LAB_NO + "'") - 1;

            for (int i = 1; i < vs1.Rows.Count; i++)
            {
                sql = "Select * from FILE03A where EMP_ID=N'" + vs1.Rows[i]["EMP_ID"] + "' ORDER BY LAB_ST DESC";
                Func.RecordSet rslb = new Func.RecordSet(sql, con);
                if (rslb.rows > 0)
                {
                    seqMax = T_String.GetMax("MAX(SEQ_NO)", "FILE06A", "emp_id=N'" + vs1.Rows[i]["EMP_ID"] + "'");
                    nav.ToolBar_Click(new ToolBarButtonClickEventArgs(nav.cmd_add));
                    vs.Rows[vs.Rows.Count - 1].UserData  = 2;
                    vs.Rows[vs.Rows.Count - 1]["LAB_ID"] = rslb.record(0, "LAB_ID");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ST"] = rslb.record(0, "LAB_ST");
                    vs.Rows[vs.Rows.Count - 1]["LAB_ED"] = rslb.record(0, "LAB_ED");
                    vs.Rows[vs.Rows.Count - 1]["LA1_ST"] = dt;
                    vs.Rows[vs.Rows.Count - 1]["LA1_SG"] = dt1;
                    vs.Rows[vs.Rows.Count - 1]["LAB_NO"] = LAB_NO;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_N2"] = maxx;
                    vs.Rows[vs.Rows.Count - 1]["SEQ_NO"] = seqMax;
                    maxx++;
                    vs.Rows[vs.Rows.Count - 1][0] = vs.Rows.Count - 1;
                    for (int c = 1; c < vs1.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1][vs1.Cols[c].Name] = vs1.Rows[i][c];
                    }
                    for (int c = 1; c < vs2.Cols.Count; c++)
                    {
                        vs.Rows[vs.Rows.Count - 1]["SAL_N" + c] = vs2.Cols[c].Name;
                        vs.Rows[vs.Rows.Count - 1]["SAL_Q" + c] = vs2.Rows[1][c];
                    }

                    // LAB_ID
                    Func.RecordSet rs1 = new Func.RecordSet("Select * from FILE05A where LAB_NO=N'" + LAB_NO + "'", con);
                    if (rs1.rows > 0)
                    {
                        string LAB_ID = T_String.GetDataFromSQL("LAB_ID", "FILE05A", "LAB_NO=N'" + LAB_NO + "'");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_ID"] + "");
                        LAB_ID = LAB_ID.Replace("#", vs1.Rows[i]["EMP_I1"] + "");
                        if (LAB_ID.IndexOf("@") >= 0)
                        {
                            double vl = max + T_String.IsNullTo0(rs1.record(0, "STT_N3"));
                            vs.Rows[vs.Rows.Count - 1]["SEQ_N1"] = vl;
                            string st = "000000000000";
                            max    = vl;
                            st     = PublicFunction.S_Left(st, T_String.IsNullTo0(rs1.record(0, "STT_N1")));
                            LAB_ID = LAB_ID.Replace("@", vl.ToString(st));
                        }
                        vs.Rows[vs.Rows.Count - 1]["LA1_ID"] = LAB_ID;
                    }


                    lb.Text   = ((int)(i * 100) / vs1.Rows.Count) + "% - " + vs1.Rows[i]["EMP_NM"];
                    pro.Value = (int)(i * 100) / vs1.Rows.Count;
                }
            }
            vs.AutoSizeCols();
            pro.Value = 100;
            con.Close();
            this.Close();
            vs.Visible = true;
        }
Esempio n. 19
0
        private void frmSearch_Load(object sender, System.EventArgs e)
        {
            try
            {
                vs.AllowEditing  = true;
                vs.AutoSearch    = AutoSearchEnum.FromCursor;
                vs.KeyActionTab  = KeyActionEnum.MoveDown;
                vs.TabIndex      = 0;
                vs.SelectionMode = SelectionModeEnum.Row;
                PublicFunction.L_Init_Label(this);

                vs.Cols.Count = _Cols + 1;
                vs.Rows.Count = _rs.rows + 1;
                int cou = 0;
                for (int c = 1; c < _Cols + 1; c++)
                {
                    vs.Cols[c].Name = _rs.Field(c - 1);
                    if (vs.Cols[c].Name == "SYS_SEL")
                    {
                        vs.Cols[c].Caption      = PublicFunction.L_GetLabel_VS("Public", vs.Cols[c].Name);
                        vs.Cols[c].AllowEditing = true;
                        vs.Cols[c].DataType     = typeof(System.Boolean);
                        vs.SelectionMode        = C1.Win.C1FlexGrid.SelectionModeEnum.CellRange;
                        vs.AfterEdit           += new RowColEventHandler(vs_AfterEdit);
                    }
                    else
                    {
                        if (cou == 0)
                        {
                            txt1.Tag = vs.Cols[c].Name;
                        }
                        if (cou == 1)
                        {
                            txt2.Tag = vs.Cols[c].Name;
                        }
                        cou++;
                        if (LB)
                        {
                            vs.Cols[c].Caption = PublicFunction.L_GetLabel_VS(_LabelID, vs.Cols[c].Name);
                        }
                        else
                        {
                            try
                            {
                                vs.Cols[c].Caption = a[c - 1] + "";
                            }
                            catch (Exception) {}
                        }
                        vs.Cols[c].AllowEditing = false;
                    }
                }

                for (int r = 0; r < _rs.rows; r++)
                {
                    vs[r + 1, 0] = r + 1;
                    for (int c = 1; c < _Cols + 1; c++)
                    {
                        vs[r + 1, c] = _rs.record(r, c - 1);
                    }
                }
                vs.AutoSizeCols();
                vs.DoubleClick += new EventHandler(vs_DoubleClick);
                vs.KeyDown     += new KeyEventHandler(vs_KeyDown);
                this.KeyDown   += new KeyEventHandler(vs_KeyDown);
                if (txt1.Tag + "" != "")
                {
                    txt1.Text = vs.Cols[txt1.Tag + ""].Caption;
                }
                if (txt2.Tag + "" != "")
                {
                    txt2.Text = vs.Cols[txt2.Tag + ""].Caption;
                }
            }
            catch
            {
                MessageBox.Show("Load Form Error");
            }
        }