示例#1
0
 public override void Dispose()
 {
     _dataSource?.Dispose();
     ThrottleMessageLiteral?.Dispose();
     DropList?.Dispose();
     TextField?.Dispose();
     SpanLiteral?.Dispose();
     SpanClosingLiteral?.Dispose();
     BrClosingLiteral?.Dispose();
     DropImage?.Dispose();
     base.Dispose();
 }
示例#2
0
    private void BindControls()
    {
        BindFunctions theBindManager = new BindFunctions();
        IQCareUtils   theUtils       = new IQCareUtils();

        theDV = new DataView((DataTable)Session["DrugTable"]);
        DataTable DTSelected = (DataTable)Session["SelectedData"];

        if (Convert.ToInt32(Session["DrugType"]) > 0)
        {
            if (Convert.ToInt32(Session["DrugType"]) == 100)
            {
                theDV.RowFilter = "DrugTypeId NOT IN (37,36,31) and Generic=0";
            }
            else
            {
                //theDV.RowFilter = "DrugTypeId = " + Session["DrugType"].ToString();
                theDV.RowFilter = "DrugTypeId = " + Session["DrugType"].ToString() + " and Generic=0 ";
            }
            theDV.Sort = "DrugName Asc";
        }
        else
        {
            //theDV.RowFilter = "DrugTypeId <> 37 ";
            theDV.RowFilter = "DrugTypeId <> 37  and DrugId <> 1  and Generic=0 ";
        }
        DataTable theDT = theUtils.CreateTableFromDataView(theDV);

        //if (theDT != null)
        //{
        //    DataView theDV1 = new DataView(theDT);
        //    theDV1.RowFilter = "DrugId <> 203";
        //    theDV1.Sort = "DrugName Asc";
        //    theDT = theUtils.CreateTableFromDataView(theDV1);
        //}


        if (theDT.Rows.Count > 0)
        {
            theBindManager.BindCheckedList(chkPharmacyselect, theDT, "DrugName", "DrugId");
            theDV.Dispose();
            theDT.Clear();
        }


        if (DTSelected != null && DTSelected.Rows.Count > 0)
        {
            foreach (DataRow dr1 in DTSelected.Rows)
            {
                foreach (ListItem item in this.chkPharmacyselect.Items)
                //foreach (DataRow dr in theDT.Rows)
                {
                    //string drugName = dr["DrugName"].ToString();
                    if (Convert.ToInt32(dr1["DrugId"]) == Convert.ToInt32(item.Value))
                    {
                        //theDT.Rows.Remove(dr);
                        item.Selected = true;
                        break;
                    }
                }
            }
        }
    }
示例#3
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            // run all background tasks here
            BackgroundWorker worker       = sender as BackgroundWorker;
            DataTable        dtComponents = dsData.Tables["Components"];
            DataView         dv           = new DataView(dtComponents);

            dv.RowFilter = "Pick = 1";
            int currentrow = 0;
            int totalrows  = dv.Count;

            Nozzle1Xoffset = dh.Nozzle1Xoffset;
            Nozzle1Yoffset = dh.Nozzle1Yoffset;
            Nozzle2Xoffset = dh.Nozzle2Xoffset;
            Nozzle2Yoffset = dh.Nozzle2Yoffset;

            if (totalrows > 0)
            {
                /* Components table columns
                 *  ComponentCode
                 *  ComponentName
                 *  PlacementX
                 *  PlacementY
                 *  PlacementRotate
                 *  PlacementNozzle
                 *
                 * component list
                 * ComponentCode
                 * ComponentValue
                 * Package
                 *
                 * PlacementHeight
                 * FeederHeight
                 * FeederX
                 * FeederY
                 * VerifywithCamera
                 * TapeFeeder
                 *
                 *
                 * */
                double pcbHeight = double.Parse(dsData.Tables["BoardInfo"].Rows[0][1].ToString());

                double feedrate = 100;
                // double placerate = 20000;
                // double feederPosX = 0;
                //double feederPosY = 0;
                //double feederPosZ = 0;
                //double placePosX = 0;
                //double placePosY = 0;
                //double ComponentRotation = 0;
                //double PlacementHeight = 0;
                //int PlacementNozzle = 1;
                //double PlaceSpeed = 100;

                // bool TapeFeeder = false;
                // bool VerifyCamera = false;



                while (currentrow < totalrows)
                {
                    if (backgroundWorkerBuildPCB.CancellationPending)
                    {
                        e.Cancel = true;
                        dv.Dispose();
                        break;
                    }



                    kfl.PlacementNozzle = int.Parse(dv[currentrow]["PlacementNozzle"].ToString());
                    kfl.PickSpeed       = feedrate;
                    kfl.PlaceSpeed      = comp.GetPlaceSpeed(dv[currentrow]["ComponentCode"].ToString(), feedrate);

                    kfl.FeederX      = CalcXLocation(comp.GetFeederX(dv[currentrow]["ComponentCode"].ToString()), kfl.PlacementNozzle);
                    kfl.FeederY      = CalcYLocation(comp.GetFeederY(dv[currentrow]["ComponentCode"].ToString()), kfl.PlacementNozzle);
                    kfl.FeederHeight = comp.GetFeederHeight(dv[currentrow]["ComponentCode"].ToString());

                    kfl.PlaceHeight = comp.GetPlacementHeight(dv[currentrow]["ComponentCode"].ToString()) - pcbHeight;

                    kfl.TapeFeeder = comp.GetComponentTapeFeeder(dv[currentrow]["ComponentCode"].ToString());

                    kfl.PlaceX        = CalcXLocation(double.Parse(dv[currentrow]["PlacementX"].ToString()), kfl.PlacementNozzle);
                    kfl.PlaceY        = CalcYLocation(double.Parse(dv[currentrow]["PlacementY"].ToString()), kfl.PlacementNozzle);
                    kfl.PlaceRotation = double.Parse(dv[currentrow]["PlacementRotate"].ToString());

                    kfl.VerifyCamera = comp.GetComponentVerifywithCamera(dv[currentrow]["ComponentCode"].ToString());

                    //feederPosX = CalcXLocation(comp.GetFeederX(dv[currentrow]["ComponentCode"].ToString()), PlacementNozzle);
                    //double feederPosY = CalcYLocation(comp.GetFeederY(dv[currentrow]["ComponentCode"].ToString()), PlacementNozzle);
                    //feederPosZ = comp.GetFeederHeight(dv[currentrow]["ComponentCode"].ToString());
                    // PlacementHeight = comp.GetPlacementHeight(dv[currentrow]["ComponentCode"].ToString()) - pcbHeight;
                    //TapeFeeder = comp.GetComponentTapeFeeder(dv[currentrow]["ComponentCode"].ToString());
                    // placePosX = CalcXLocation(double.Parse(dv[currentrow]["PlacementX"].ToString()), kfl.PlacementNozzle);
                    //placePosY = CalcYLocation(double.Parse(dv[currentrow]["PlacementY"].ToString()), kfl.PlacementNozzle);
                    //ComponentRotation = double.Parse(dv[currentrow]["PlacementRotate"].ToString());
                    //VerifyCamera = comp.GetComponentVerifywithCamera(dv[currentrow]["ComponentCode"].ToString());

                    if (currentrow == 0)
                    {
                        SetFeederOutputs(comp.GetFeederID(dv[currentrow]["ComponentCode"].ToString())); // send feeder to position
                    }
                    //MessageBox.Show(kfl.FeederY.ToString());
                    //kf.MoveSingleFeed(kfl.PickSpeed, 100, kfl.FeederY, ClearHeight, ClearHeight, 0, 0);

                    kf.MoveSingleFeed(kfl.PickSpeed, kfl.FeederX, kfl.FeederY, ClearHeight, ClearHeight, 0, 0);


                    if (comp.GetComponentTapeFeeder(dv[currentrow]["ComponentCode"].ToString()))
                    {
                        while (!usbController.GetFeederReadyStatus())
                        {
                            Thread.Sleep(10);
                        }
                        Thread.Sleep(50);
                        if (kfl.PlacementNozzle == 1)
                        {
                            // use picker 1
                            kf.MoveSingleFeed(kfl.PickSpeed, kfl.FeederX, kfl.FeederY, kfl.FeederHeight, ClearHeight, 0, 0);
                            Thread.Sleep(200);
                            // go down and turn on suction
                            usbController.SetVAC1(true);
                            Thread.Sleep(150);
                            kf.MoveSingleFeed(kfl.PickSpeed, kfl.FeederX, kfl.FeederY, ClearHeight, ClearHeight, 0, 0);
                        }
                        else
                        {
                            // nozzle 2 on tape feeder
                            kf.MoveSingleFeed(kfl.PickSpeed, kfl.FeederX, kfl.FeederY, ClearHeight, kfl.FeederHeight, 0, 0);
                            Thread.Sleep(200);
                            // go down and turn on suction
                            usbController.SetVAC2(true);
                            Thread.Sleep(150);
                            kf.MoveSingleFeed(kfl.PickSpeed, kfl.FeederX, kfl.FeederY, ClearHeight, ClearHeight, 0, 0);
                        }
                    }
                    else
                    {
                        // use picker 2
                        while (usbController.CheckChipMotorRunning())
                        {
                            Thread.Sleep(10);
                        }
                        kf.MoveSingleFeed(kfl.PickSpeed, kfl.FeederX, kfl.FeederY, ClearHeight, kfl.FeederHeight, 0, 0);
                        Thread.Sleep(200);

                        usbController.SetVAC2(true);
                        Thread.Sleep(300);
                        kf.MoveSingleFeed(kfl.PickSpeed, kfl.FeederX, kfl.FeederY, ClearHeight, ClearHeight, 0, 0);
                    }
                    // send picker to pick next item
                    if (currentrow >= 0 && (currentrow + 1) < totalrows)
                    {
                        Thread.Sleep(100);
                        Thread.Sleep(100);


                        SetFeederOutputs(comp.GetFeederID(dv[currentrow + 1]["ComponentCode"].ToString())); // send feeder to position
                    }


                    // check if place speed needs to go slower


                    // rotate head and place component

                    //SetResultsLabelText("Placing Component");
                    if (comp.GetComponentTapeFeeder(dv[currentrow]["ComponentCode"].ToString()) && (kfl.PlacementNozzle == 1))
                    {
                        /*
                         * if (kfl.VerifyCamera)
                         * {
                         *  kfl = CheckWithCamera(kfl, kf, 1, usbController, img);
                         *  kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, ClearHeight, ClearHeight, 0, kfl.PlaceRotation);
                         *  kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, kfl.PlaceHeight, ClearHeight, 0, kfl.PlaceRotation);
                         *
                         * } else
                         * {
                         */
                        kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, ClearHeight, ClearHeight, 0, kfl.PlaceRotation);
                        kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, kfl.PlaceHeight, ClearHeight, 0, kfl.PlaceRotation);

                        // }
                        Thread.Sleep(200);
                        usbController.SetVAC1(false);
                        Thread.Sleep(50);
                        kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, ClearHeight, ClearHeight, 0, kfl.PlaceRotation);
                    }
                    else
                    {
                        // use picker 2  CalcXwithNeedleSpacing

                        /*
                         * if (kfl.VerifyCamera)
                         * {
                         *  kfl = CheckWithCamera(kfl, kf, 2, usbController, img);
                         *  kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, ClearHeight, ClearHeight, kfl.PlaceRotation, 0);
                         *  Thread.Sleep(200);
                         *  kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, ClearHeight, kfl.PlaceHeight, kfl.PlaceRotation, 0);
                         * }
                         * else
                         * {*/
                        kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, ClearHeight, ClearHeight, kfl.PlaceRotation, 0);
                        Thread.Sleep(200);
                        kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, ClearHeight, kfl.PlaceHeight, kfl.PlaceRotation, 0);

                        //}

                        // go down and turn off suction
                        Thread.Sleep(300);
                        usbController.SetVAC2(false);
                        Thread.Sleep(200);
                        kf.MoveSingleFeed(kfl.PlaceSpeed, kfl.PlaceX, kfl.PlaceY, ClearHeight, ClearHeight, kfl.PlaceRotation, 0);
                    }

                    currentrow++;
                }
                // move near to home point
                kf.MoveSingleFeed(kfl.PickSpeed, 10, 10, 10, 10, 0, 0);
            }
            else
            {
                MessageBox.Show("Board file not loaded");
            }
            backgroundWorkerBuildPCB.CancelAsync();
            usbController.SetResetFeeder();
            usbController.RunVibrationMotor(MotorRunLoop);
            kf.RunHomeAll();

            //dtLog.WriteXml(_LogFile);

            dv.Dispose();
            dtComponents.Dispose();
        }
示例#4
0
        /// <summary>
        /// 读取或绑定数据
        /// </summary>
        private void BindData()
        {
            //定义变量
            string strSql, strTypeID, strFileName, strID;

            //获取本页面文件名称
            strFileName = Request.Url.AbsolutePath.ToLower();
            strFileName = System.IO.Path.GetFileName(strFileName);

            if (strFileName.ToLower().IndexOf("pro") > -1)
            {
                pl1.Visible = true;
            }
            else if (strFileName.ToLower().IndexOf("jm") > -1)
            {
                pl2.Visible = true;
            }
            else
            {
                pl3.Visible = true;
            }

            //赋值变量
            strTypeID = Request.QueryString["TypeID"];
            strID     = Request.QueryString["ID"];
            strSql    = "select * from T_ProType where isShow=1 order by sid,ID";

            //判断变量
            if (!FunctionClass.CheckStr(strTypeID, 1))
            {
                strTypeID = "";
            }
            if (!FunctionClass.CheckStr(strID, 1))
            {
                strID = "";
            }

            //打开数据库连接
            DataClass     myData = new DataClass();
            SqlConnection myConn = myData.ConnOpen();

            DataSet myDs = myData.GetDataSet(strSql, myConn);

            //产品分类
            DataView myDv = new DataView(myDs.Tables[0], "", "", DataViewRowState.CurrentRows);

            for (int i = 0; i < myDv.Count; i++)
            {
                lbPro.Text += "<li";

                if (strTypeID == myDv[i]["ID"].ToString())
                {
                    lbPro.Text += " class=\"curr\"";
                }

                lbPro.Text += "><a href=\"products.aspx?TypeID=" + myDv[i]["ID"].ToString()
                              + "\">" + myDv[i]["TypeCalled"].ToString() + "</a></li>";
            }
            myDv.Dispose();

            myDs.Dispose();

            //关于我们菜单
            lbAbout.Text = "<li";
            if (strID == "3")
            {
                lbAbout.Text += " class=\"curr\"";
            }
            lbAbout.Text += "><a href=\"about.aspx?id=3\">关于我们</a></li><li";
            if (strID == "13")
            {
                lbAbout.Text += " class=\"curr\"";
            }
            lbAbout.Text += "><a href=\"about.aspx?id=13\">店铺风采</a></li><li";
            if (strFileName.IndexOf("new") > -1)
            {
                lbAbout.Text += " class=\"curr\"";
            }
            lbAbout.Text += "><a href=\"news.aspx\">新闻动态</a></li><li";
            if (strID == "4")
            {
                lbAbout.Text += " class=\"curr\"";
            }
            lbAbout.Text += "><a href=\"about.aspx?id=4\">联系我们</a></li>";

            //加盟菜单
            lbJM.Text = "<li";
            if (strID == "7")
            {
                lbJM.Text += " class=\"curr\"";
            }
            lbJM.Text += "><a href=\"jm.aspx?id=7\">加盟条件</a></li><li";
            if (strID == "8")
            {
                lbJM.Text += " class=\"curr\"";
            }
            lbJM.Text += "><a href=\"jm.aspx?id=8\">投资预算</a></li><li";
            if (strID == "9")
            {
                lbJM.Text += " class=\"curr\"";
            }
            lbJM.Text += "><a href=\"jm.aspx?id=9\">加盟流程</a></li><li";
            if (strID == "10")
            {
                lbJM.Text += " class=\"curr\"";
            }
            lbJM.Text += "><a href=\"jm.aspx?id=10\">加盟支持</a></li><li";
            if (strFileName.IndexOf("book") > -1)
            {
                lbJM.Text += " class=\"curr\"";
            }
            lbJM.Text += "><a href=\"jm.aspx?id=11\">加盟问答</a></li><li";
            if (strFileName.IndexOf("add") > -1)
            {
                lbJM.Text += " class=\"curr\"";
            }
            lbJM.Text += "><a href=\"jm_add.aspx\">在线申请</a></li>";

            //关闭数据库连接
            myData.ConnClose(myConn);
        }
示例#5
0
        public void TestAttachedDataView()
        {
            DataSession.Execute("create table TestForAttachedDataView { ID : Integer, Name : String, key { ID } };");
            DataSession.Execute("insert row { 1 ID, 'Joe' Name } into TestForAttachedDataView;");

            DataView LDataView = DataSession.OpenDataView("TestForAttachedDataView");

            try
            {
                Form LForm = new Form();
                try
                {
                    DataSource LSource = new DataSource();
                    LSource.DataSet = LDataView;
                    DBGrid LGrid = new DBGrid();
                    LGrid.Source = LSource;
                    LGrid.Dock   = DockStyle.Fill;
                    LForm.Controls.Add(LGrid);
                    LForm.Show();

                    Application.DoEvents();

                    if (!LDataView.IsEmpty())
                    {
                        LDataView.First();
                        LDataView.Edit();
                        LDataView["Name"].AsString = "John";
                        LDataView.Refresh();
                    }

                    Application.DoEvents();

                    LDataView.Insert();
                    LDataView["ID"].AsInt32    = 2;
                    LDataView["Name"].AsString = "Jacob";
                    LDataView.Post();

                    Application.DoEvents();

                    //LDataView.Delete();
                    DataSession.Execute("delete TestForAttachedDataView where ID = 2");
                    LDataView.Refresh();

                    Application.DoEvents();

                    if (LDataView["ID"].AsInt32 != 1)
                    {
                        throw new Exception("Data View Refresh After Delete Failed");
                    }

                    if (LDataView.IsEmpty())
                    {
                        throw new Exception("Data View Delete Failed");
                    }
                }
                finally
                {
                    LForm.Dispose();
                }
            }
            finally
            {
                LDataView.Dispose();
            }
        }
        public static void          setGridDataSource(DataGridView aDataGridView, DataTable aDataTable, string aFilter,
                                                      ref int[] aColumnsWidth, ref DataView aDataView, ref string aSelect)
        {
            List <string> lSelectedItems     = new List <string>();
            int           lFirstRowIndex     = 0;
            int           lSortedColumnIndex = 0;
            var           lListSortDirection = ListSortDirection.Ascending;

            if (aDataTable != null && String.IsNullOrWhiteSpace(aSelect) == false)
            {
                lSelectedItems.Add(aSelect);
            }

            if (aDataGridView.DataSource != null)
            {
                #region Row

                if (aDataTable != null && lSelectedItems.Count == 0 && aDataGridView.SelectedRows.Count != 0)
                {
                    lFirstRowIndex = aDataGridView.FirstDisplayedScrollingRowIndex;

                    int lCount = aDataGridView.SelectedRows.Count;
                    for (int i = 0; i < lCount; i++)
                    {
                        lSelectedItems.Add(aDataGridView.SelectedRows[i].Cells[0].Value.ToString());
                    }
                }

                #endregion

                #region Column

                if (aDataGridView.SortedColumn != null)
                {
                    lSortedColumnIndex = aDataGridView.SortedColumn.Index;
                    switch (aDataGridView.SortOrder)
                    {
                    case SortOrder.Ascending: lListSortDirection = ListSortDirection.Ascending;
                        break;

                    case SortOrder.Descending: lListSortDirection = ListSortDirection.Descending;
                        break;
                    }
                }

                aColumnsWidth = GridUtils.saveColumnsWidth(aDataGridView, aColumnsWidth);

                #endregion

                aDataGridView.DataSource = null;
                aDataView.Dispose();
                aDataView = null;
            }

            if (aDataTable != null)
            {
                aDataView                = aDataTable.DefaultView;
                aDataView.RowFilter      = aFilter;
                aDataGridView.DataSource = aDataView;

                #region Column

                aDataGridView.Sort(aDataGridView.Columns[lSortedColumnIndex], lListSortDirection);

                #endregion

                #region Row

                if (aDataGridView.RowCount > 0)
                {
                    if (lFirstRowIndex >= 0 && lFirstRowIndex < aDataGridView.RowCount)
                    {
                        try     // Иначе в свёрнутом виде ругается: No room is available to display rows
                        {
                            aDataGridView.FirstDisplayedScrollingRowIndex = lFirstRowIndex;
                        }
                        catch { }
                    }

                    if (aDataGridView.MultiSelect)
                    {
                        aDataGridView.Rows[0].Selected = false;
                    }

                    int lRow;
                    int lCount = lSelectedItems.Count;
                    for (int i = 0; i < lCount; i++)
                    {
                        lRow = findRow(aDataGridView, 0, lSelectedItems[i]);
                        if (lRow != -1)
                        {
                            aDataGridView.Rows[lRow].Selected = true;
                        }
                    }

                    if (aDataGridView.SelectedRows.Count == 1)
                    {
                        int lSelectedRowIndex = aDataGridView.SelectedRows[0].Index;
                        int lFirst            = aDataGridView.FirstDisplayedScrollingRowIndex;
                        int lRowCount         = aDataGridView.DisplayedRowCount(true);

                        if (lSelectedRowIndex < lFirst || lSelectedRowIndex > lFirst + lRowCount - 1)
                        {
                            try     // Иначе в свёрнутом виде ругается: No room is available to display rows
                            {
                                aDataGridView.FirstDisplayedScrollingRowIndex = lSelectedRowIndex;
                            }
                            catch { }
                        }
                    }
                }

                #endregion
            }

            aSelect = "";
        }
示例#7
0
        private void BindData(String sortDirection)
        {
            Logger mLog = Logger.Instance();

            DataTable oTable = new DataTable("MyTable");

            oTable.Columns.Add("COL1", Type.GetType("System.String"));
            oTable.Columns.Add("COL2", Type.GetType("System.String"));
            DataRow oRow = oTable.NewRow();

            oRow         = oTable.NewRow();
            oRow["COL1"] = "Chapter(10)";
            oRow["COL2"] = "Chapter(10)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Chapter 2 Ep 2-3";
            oRow["COL2"] = "Chapter 2 Ep 2-3";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Chapter 2 Ep 1-2";
            oRow["COL2"] = "Chapter 2 Ep 1-2";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "";
            oRow["COL2"] = "";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Rocky(IV)";
            oRow["COL2"] = "Rocky(IV)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Chapter(1)";
            oRow["COL2"] = "Chapter(1)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Chapter(11)";
            oRow["COL2"] = "Chapter(11)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Rocky(I)";
            oRow["COL2"] = "Rocky(I)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Rocky(II)";
            oRow["COL2"] = "Rocky(II)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Rocky(IX)";
            oRow["COL2"] = "Rocky(IX)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Rocky(X)";
            oRow["COL2"] = "Rocky(X)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Chapter(2)";
            oRow["COL2"] = "Chapter(2)";
            oTable.Rows.Add(oRow);
            oRow         = oTable.NewRow();
            oRow["COL1"] = "Chapter 1 Ep 2-3";
            oRow["COL2"] = "Chapter 1 Ep 2-3";
            oTable.Rows.Add(oRow);
            DataView myDV = oTable.DefaultView;

            Framework.Common.SortTable mySorter = new Framework.Common.SortTable();
            String mColName = "COL1";

            mySorter.Sort(oTable, mColName, sortDirection);
            StartTime.Text = mySorter.StartTime.ToString();
            StopTime.Text  = mySorter.StopTime.ToString();
            TimeSpan ts = mySorter.StopTime.Subtract(mySorter.StartTime);

            mLog.Debug(ts.TotalMilliseconds.ToString());
            lblTotalTime.Text    = ts.TotalMilliseconds.ToString();
            GridView2.DataSource = oTable;
            GridView2.DataBind();
            DropDownList2.DataSource    = oTable;
            DropDownList2.DataTextField = "COL1";
            DropDownList2.DataBind();
            string mySort = "COL1 " + sortDirection;

            myDV.Sort = mySort;
            DropDownList3.DataSource    = myDV;
            DropDownList3.DataTextField = "COL1";
            DropDownList3.DataBind();
            GridView3.DataSource = myDV;
            GridView3.DataBind();
            oTable.Dispose();
            myDV.Dispose();
        }
示例#8
0
        private void loadGrid_LongOrder()
        {
            try
            {
                if (this.dataGrid_LongOrder.VisibleRowCount > 0)
                {
                    this.dataGrid_LongOrder.CurrentCell = new DataGridCell(0, 0);
                }
            }
            catch
            {
            }
            DataTable dtNeed = new DataTable();

            if (_isPrint)
            {
                DataTable dtOrdRec  = new DbQuery().GetBinOrders(1, _babyID, _binID, InstanceForm._currentDept.DeptId);
                DataTable dtOrdRec1 = new DbQuery().GetBinOrders(2, _babyID, _binID, InstanceForm._currentDept.DeptId);
                dtNeed = dtOrdRec.Clone();
                foreach (DataRow drNeed in dtOrdRec.Rows)
                {
                    if (drNeed["嘱号"].ToString().Trim().Equals(_grpID))
                    {
                        dtNeed.Rows.Add(drNeed.ItemArray);
                    }
                }
                foreach (DataRow drNeed in dtOrdRec1.Rows)
                {
                    if (drNeed["嘱号"].ToString().Trim().Equals(_grpID))
                    {
                        DataRow dr1 = dtNeed.NewRow();
                        foreach (DataColumn dc in dtOrdRec1.Columns)
                        {
                            if (dtNeed.Columns.Contains(dc.ColumnName))
                            {
                                dr1[dc.ColumnName] = drNeed[dc.ColumnName];
                            }
                        }
                        dtNeed.Rows.Add(dr1);
                    }
                }
                dtNeed.AcceptChanges();
            }

            DataTable myTb = _isPrint ? dtNeed : _dtKss;

            DataView tempDataView = new DataView(myTb, "", "开始时间,嘱号,serial_no", DataViewRowState.CurrentRows);

            myTb = insertRow(tempDataView, myTb);//将数据视图转化为表
            tempDataView.Dispose();

            for (int i = 0; i < myTb.Rows.Count; i++)
            {   //去多余的“0”
                myTb.Rows[i]["剂量"] = removeZero(Convert.ToDecimal(myTb.Rows[i]["剂量"].ToString()));
            }
            DataTable myTbb = CheckGrdDataLong(myTb);
            //DataRow myRow = myTbb.NewRow();
            ////myRow["ID"]=1;//ID为0,表示不为正规行
            //myTbb.Rows.Add(myRow);
            DataTable myTbBk = myTbb.Copy();

            this.dataGrid_LongOrder.DataSource = null;
            this.dataGrid_LongOrder.DataSource = myTbBk;
            //以前的
            //this.dataGrid_LongOrder.CurrentRowIndex = myTbBk.Rows.Count - 1;
            try
            {
                DataGridCell cel;
                if (myTbBk.Rows.Count - 2 >= 0)
                {
                    cel = new DataGridCell(myTbBk.Rows.Count - 2, 0);

                    this.dataGrid_LongOrder.CurrentCell = cel;
                }
            }
            catch { }

            if (this.dataGrid_LongOrder.TableStyles.Count > 0)
            {
                this.dataGrid_LongOrder.TableStyles[0].ReadOnly = true;
            }
            Cursor = Cursors.Default;
        }
示例#9
0
        /// <summary>
        /// 绑定读取数据
        /// </summary>
        private void BindData()
        {
            //定义变量
            string strSql, strNewType, strKeyWords, strIsRecommend;

            //变量赋值
            strNewType     = Request.QueryString["NewType"];
            strKeyWords    = Request.QueryString["keyword"];
            strIsRecommend = Request.QueryString["IsRecommend"];

            //判断变量
            if (!FunctionClass.CheckStr(strNewType, 1))
            {
                strNewType = "1";
            }
            if (!FunctionClass.CheckStr(strIsRecommend, 1))
            {
                strIsRecommend = "";
            }

            //打开数据库
            DataClass     myData = new DataClass();
            SqlConnection myConn = myData.ConnOpen();

            //sql语句
            strSql = " where IsShow=1";
            if (strNewType != "")
            {
                strSql += " and (" + myData.GetNewTypeIDSql(strNewType, myConn) + "NewType=" + strNewType + ")";
            }

            if (FunctionClass.CheckStr(strKeyWords, 0))
            {
                strSql        += " and (Title like '%" + strKeyWords.Replace("'", "''") + "%' or Content like '%" + strKeyWords.Replace("'", "''") + "%')";
                tbKeyword.Text = strKeyWords;
            }

            if (strIsRecommend != "")
            {
                strSql += " and IsRecommend=" + strIsRecommend;
            }

            //初始化分页变量
            int intPageIndex       = FunctionClass.CurrentPage();
            int intPageSize        = 10;
            int intPageCount       = 0;
            int intPageRecordcount = 0;

            //创建Dataset对象读取数据记录集
            DataSet myDs = myData.GetDataSet("T_News", strSql, "SID asc,NoteTime desc", intPageIndex, intPageSize,
                                             ref intPageCount, ref intPageRecordcount, myConn);

            DataView myDv = new DataView(myDs.Tables[0], "  ", "", DataViewRowState.CurrentRows);

            for (int i = 0; i < myDv.Count; i++)
            {
                lbList.Text += "<tr";
                if (i % 2 != 0)
                {
                    lbList.Text += " class='curr'";
                }
                lbList.Text += ">"
                               + "<td width=\"75\">" + (intPageSize * (intPageIndex - 1) + i + 1) + "</td>"
                               + "<th width=\"395\"><a href=\"newinfo.aspx?id=" + myDv[i]["ID"].ToString()
                               + "\" target=\"_blank\">" + myDv[i]["Title"].ToString() + "</a></th>"
                               + "<td width=\"130\">" + DateTime.Parse(myDv[i]["NoteTime"].ToString()).ToString("yyyy-MM-dd") + "</td>"
                               + "<td>【<a href=\"newinfo.aspx?id=" + myDv[i]["ID"].ToString() + "\" target=\"_blank\">查看详情</a>】</td>"
                               + "</tr>";
            }
            myDv.Dispose();

            //分页
            lbPageBar.Text = FunctionClass.GetPageBar(intPageIndex, intPageRecordcount, intPageCount, 4,
                                                      FunctionClass.GetNewURL("page", "{page}", FunctionClass.PageURL),
                                                      "<img src=\"images/news_11.jpg\" width=\"12\" height=\"12\" />",
                                                      "<img src=\"images/news_12.jpg\" width=\"12\" height=\"12\" />",
                                                      "<img src=\"images/news_14.jpg\" width=\"12\" height=\"12\" />",
                                                      "<img src=\"images/news_15.jpg\" width=\"12\" height=\"12\" />", false, false);
            myDs.Dispose();

            lbCalled.Text        = "新闻中心";
            lbCalled1.Text       = "News Center";
            hyCalled.Text        = "新闻中心";
            hyCalled.NavigateUrl = "news.aspx";

            //关闭数据库
            myData.ConnClose(myConn);
        }
示例#10
0
        private void Bt_Load_Click(object sender, RoutedEventArgs e)
        {
            while (dsData.Tables.Count > 0)
            {
                DataTable table = dsData.Tables[0];
                if (dsData.Tables.CanRemove(table))
                {
                    dsData.Tables.Remove(table);
                }
            }

            // Configure open file dialog box
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "";                           // Default file name
            dlg.DefaultExt = ".xml";                       // Default file extension
            dlg.Filter     = "Xml documents (.xml)|*.xml"; // Filter files by extension

            // Show open file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                dsData.ReadXml(dlg.FileName);

                dtComponents = dsData.Tables["Components"];

                dtBoardInfo = dsData.Tables["BoardInfo"];


                ItemTitle.Text = dsData.Tables["BoardInfo"].Rows[0][0].ToString();
                csfeeder.Text  = dsData.Tables["BoardInfo"].Rows[0][2].ToString();

                // populate feeders table
                Components comp = new Components();
                DataSet    ds   = comp.POPComponentsTable();

                DataView dvFeeders = new DataView(ds.Tables[0]);
                dvFeeders.Sort = "FeederID ASC";

                DataView dvFeederComponents = new DataView(dtComponents);



                for (int x = 0; x < dvFeeders.Count; x++)
                {
                    DataView dvfilter = new DataView(dtComponents);

                    dvfilter.RowFilter = "ComponentCode = " + dvFeeders[x]["ComponentCode"].ToString();
                    if (dvfilter.Count > 0)
                    {
                        dtLog.Rows.Add(dvFeeders[x]["ComponentValue"], dvFeeders[x]["Package"], dvFeeders[x]["TapeFeeder"].ToString(), dvFeeders[x]["FeederID"], dvFeeders[x]["ComponentCode"], 0);
                    }
                    dvfilter.Dispose();
                }



                dtLog.WriteXml(LogFile);

                /*
                 * for (int x = 0; x < dvFeederComponents.Count; x++)
                 * {
                 *  DataView dvfilter = new DataView(ds.Tables[0]);
                 *
                 *  dvfilter.RowFilter = "ComponentCode = " + dvFeederComponents[x]["ComponentCode"].ToString();
                 *  if (dvfilter.Count > 0)
                 *  {
                 *      table.Rows.Add(dvfilter[0]["ComponentValue"], dvfilter[0]["Package"], dvfilter[0]["TapeFeeder"].ToString(), dvfilter[0]["FeederID"], dvfilter[0]["ComponentCode"]);
                 *  }
                 *  dvfilter.Dispose();
                 *
                 *
                 * }
                 *
                 */
                //ComponentCode

                // ComponentValue
                //    FeederID
                //    TapeFeeder
                _dgFeeders.ItemsSource = dtLog.DefaultView;
            }



            _dgComponents.ItemsSource = dtComponents.DefaultView;
        }
    protected void BindDropdown()
    {
        BindFunctions BindManager = new BindFunctions();
        IQCareUtils   theUtils    = new IQCareUtils();
        DataSet       theDSXML    = new DataSet();

        theDSXML.ReadXml(MapPath("..\\XMLFiles\\AllMasters.con"));

        DataView  theDV = new DataView();
        DataTable theDT = new DataTable();

        //if (Request.QueryString["Name"] == "Add")
        if (Convert.ToInt32(Session["PatientId"]) == 0)
        {
            //Marital Status
            theDV           = new DataView(theDSXML.Tables["Mst_Decode"]);
            theDV.RowFilter = "DeleteFlag=0 and CodeID=12 and SystemID IN(" + Session["SystemId"].ToString() + ",0)";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(DDMaritalStatus, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }
            //Referred From
            theDV           = new DataView(theDSXML.Tables["mst_pmtctdecode"]);
            theDV.RowFilter = "CodeID=28 and SystemID IN(" + Session["SystemId"].ToString() + ", 0) and DeleteFlag=0";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddReferredFrom, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }

            // Village/Town/City
            theDV           = new DataView(theDSXML.Tables["mst_Village"]);
            theDV.RowFilter = "SystemID IN(" + Session["SystemId"].ToString() + ", 0) and DeleteFlag=0";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddVillageName, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }

            //District
            theDV           = new DataView(theDSXML.Tables["Mst_District"]);
            theDV.RowFilter = "SystemID IN (" + Session["SystemId"].ToString() + ",0) and DeleteFlag=0";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddDistrict, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }
            //Transferring Information from FindAdd /ART Enrolment Form
        }
        else
        {
            //Marital Status
            theDV           = new DataView(theDSXML.Tables["Mst_Decode"]);
            theDV.RowFilter = "CodeID=12 and SystemID IN(" + Session["SystemId"].ToString() + ",0)";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(DDMaritalStatus, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }
            //Referred From
            theDV           = new DataView(theDSXML.Tables["mst_pmtctdecode"]);
            theDV.RowFilter = "CodeID=28 and SystemID IN(" + Session["SystemId"].ToString() + ",0)";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddReferredFrom, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }

            // Village/Town/City
            theDV           = new DataView(theDSXML.Tables["mst_Village"]);
            theDV.RowFilter = "SystemID IN(" + Session["SystemId"].ToString() + ",0)";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddVillageName, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }

            //District
            theDV           = new DataView(theDSXML.Tables["Mst_District"]);
            theDV.RowFilter = "SystemID IN(" + Session["SystemId"].ToString() + ",0)";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddDistrict, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }
        }

        if (!IsPostBack)
        {
            //if (Session["PatientId"] == null || Convert.ToString(Session["PatientId"]) == "0")
            //{
            //    Session["PatientId"] = Request.QueryString["PatientId"];
            //}


            //if (Request.QueryString["PatientID"] == null)
            if (Session["PatientId"] == null || System.Convert.ToInt32(Session["PatientId"]) == 0)
            {
                Hashtable theHT = (Hashtable)Session["EnrollParams"];
                TxtFirstName.Text = theHT["FirstName"].ToString();
                TxtLastName.Text  = theHT["LastName"].ToString();
                //txthospitalID.Text = theHT["ClinicNo"].ToString();
                TxtDOB.Text   = theHT["Date of Birth"].ToString();
                DDGender.Text = theHT["Sex"].ToString();
                Session.Remove("EnrollParams");
            }
            else
            {
                IPatientRegistration MgrPMTCT = (IPatientRegistration)ObjectFactory.CreateInstance(ObjFactoryParameter);
                int patientID = System.Convert.ToInt32(Session["PatientId"]); //Convert.ToInt32(Request.QueryString["PatientID"]);
                ViewState["ptnid"] = patientID;
                DataTable RecordDT = MgrPMTCT.GetPatientRecord(patientID);
                this.TxtLastName.Text       = RecordDT.Rows[0]["LastName"].ToString();
                this.TxtFirstName.Text      = RecordDT.Rows[0]["FirstName"].ToString();
                this.DDGender.SelectedValue = RecordDT.Rows[0]["Sex"].ToString();
                this.TxtDOB.Text            = ((DateTime)RecordDT.Rows[0]["DOB"]).ToString(Session["AppDateFormat"].ToString());
            }

            /////////////////////////////////////////////////////////////////////////////////////////////////
        }
    }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            // run all background tasks here
            BackgroundWorker worker       = sender as BackgroundWorker;
            DataTable        dtComponents = dsData.Tables["Components"];
            DataView         dv           = new DataView(dtComponents);

            dv.RowFilter = "Pick = 1";
            int currentrow = 0;
            int totalrows  = dv.Count;

            Nozzle1Xoffset = dh.Nozzle1Xoffset;
            Nozzle1Yoffset = dh.Nozzle1Yoffset;
            Nozzle2Xoffset = dh.Nozzle2Xoffset;
            Nozzle2Yoffset = dh.Nozzle2Yoffset;

            if (totalrows > 0)
            {
                /* Components table columns
                 *  ComponentCode
                 *  ComponentName
                 *  PlacementX
                 *  PlacementY
                 *  PlacementRotate
                 *  PlacementNozzle
                 *
                 * component list
                 * ComponentCode
                 * ComponentValue
                 * Package
                 *
                 * PlacementHeight
                 * FeederHeight
                 * FeederX
                 * FeederY
                 * VerifywithCamera
                 * TapeFeeder
                 *
                 *
                 * */
                double pcbHeight = double.Parse(dsData.Tables["BoardInfo"].Rows[0][1].ToString());

                double feedrate   = 20000;
                double feederPosX = 0;
                double feederPosY = 0;
                double feederPosZ = 0;
                double placePosX  = 0;
                double placePosY  = 0;
                //double placePosZ = 0;
                // double placePosA = 0;
                // double placePosRotateZ = 0;
                // double placePosRotateB = 0;
                double ComponentRotation = 0;
                double PlacementHeight   = 0;
                int    PlacementNozzle   = 1;
                bool   TapeFeeder        = false;

                while (currentrow < totalrows)
                {
                    if (backgroundWorkerBuildPCB.CancellationPending)
                    {
                        e.Cancel = true;
                        dv.Dispose();
                        break;
                    }
                    PlacementNozzle = int.Parse(dv[currentrow]["PlacementNozzle"].ToString());


                    feederPosX = CalcXLocation(comp.GetFeederX(dv[currentrow]["ComponentCode"].ToString()), PlacementNozzle);
                    feederPosY = CalcYLocation(comp.GetFeederY(dv[currentrow]["ComponentCode"].ToString()), PlacementNozzle);

                    feederPosZ      = comp.GetFeederHeight(dv[currentrow]["ComponentCode"].ToString());
                    PlacementHeight = comp.GetPlacementHeight(dv[currentrow]["ComponentCode"].ToString()) - pcbHeight;

                    TapeFeeder = comp.GetComponentTapeFeeder(dv[currentrow]["ComponentCode"].ToString());

                    placePosX = CalcXLocation(double.Parse(dv[currentrow]["PlacementX"].ToString()), PlacementNozzle);
                    placePosY = CalcYLocation(double.Parse(dv[currentrow]["PlacementY"].ToString()), PlacementNozzle);

                    ComponentRotation = double.Parse(dv[currentrow]["PlacementRotate"].ToString());


                    PlacementNozzle = int.Parse(dv[currentrow]["PlacementNozzle"].ToString());


                    if (currentrow == 0)
                    {
                        SetFeederOutputs(comp.GetFeederID(dv[currentrow]["ComponentCode"].ToString())); // send feeder to position
                    }



                    kf.MoveSingleFeed(feedrate, feederPosX, feederPosY, ClearHeight, ClearHeight, 0, 0);


                    if (comp.GetComponentTapeFeeder(dv[currentrow]["ComponentCode"].ToString()))
                    {
                        while (!usbController.getFeederReadyStatus())
                        {
                            Thread.Sleep(10);
                        }
                        Thread.Sleep(50);
                        // use picker 1
                        kf.MoveSingleFeed(feedrate, feederPosX, feederPosY, feederPosZ, ClearHeight, 0, 0);
                        Thread.Sleep(200);
                        // go down and turn on suction
                        usbController.setVAC1(true);
                        Thread.Sleep(150);
                        kf.MoveSingleFeed(feedrate, feederPosX, feederPosY, ClearHeight, ClearHeight, 0, 0);
                    }
                    else
                    {
                        // use picker 2
                        while (usbController.CheckChipMotorRunning())
                        {
                            Thread.Sleep(10);
                        }
                        kf.MoveSingleFeed(feedrate, feederPosX, feederPosY, ClearHeight, feederPosZ, 0, 0);
                        Thread.Sleep(200);

                        usbController.setVAC2(true);
                        Thread.Sleep(300);
                        kf.MoveSingleFeed(feedrate, feederPosX, feederPosY, ClearHeight, ClearHeight, 0, 0);
                    }
                    // send picker to pick next item
                    if (currentrow >= 0 && (currentrow + 1) < totalrows)
                    {
                        Thread.Sleep(100);
                        Thread.Sleep(100);


                        SetFeederOutputs(comp.GetFeederID(dv[currentrow + 1]["ComponentCode"].ToString())); // send feeder to position
                    }

                    // rotate head


                    //SetResultsLabelText("Placing Component");
                    if (comp.GetComponentTapeFeeder(dv[currentrow]["ComponentCode"].ToString()))
                    {
                        kf.MoveSingleFeed(feedrate, placePosX, placePosY, ClearHeight, ClearHeight, 0, ComponentRotation);

                        kf.MoveSingleFeed(feedrate, placePosX, placePosY, PlacementHeight, ClearHeight, 0, ComponentRotation);
                        Thread.Sleep(200);
                        usbController.setVAC1(false);
                        Thread.Sleep(50);
                        kf.MoveSingleFeed(feedrate, placePosX, placePosY, ClearHeight, ClearHeight, 0, ComponentRotation);
                    }
                    else
                    {
                        // use picker 2  CalcXwithNeedleSpacing

                        kf.MoveSingleFeed(feedrate, placePosX, placePosY, ClearHeight, ClearHeight, ComponentRotation, 0);
                        Thread.Sleep(200);
                        kf.MoveSingleFeed(feedrate, placePosX, placePosY, ClearHeight, PlacementHeight, ComponentRotation, 0);
                        // go down and turn off suction
                        Thread.Sleep(300);

                        usbController.setVAC2(false);
                        Thread.Sleep(200);
                        kf.MoveSingleFeed(feedrate, placePosX, placePosY, ClearHeight, ClearHeight, ComponentRotation, 0);
                    }

                    currentrow++;
                }
            }
            else
            {
                MessageBox.Show("Board file not loaded");
            }
            backgroundWorkerBuildPCB.CancelAsync();
            usbController.setResetFeeder();
            usbController.RunVibrationMotor(MotorRunLoop);
            kf.RunHomeAll();


            dv.Dispose();
            dtComponents.Dispose();
        }
示例#13
0
        /// <summary>
        /// 绑定读取数据
        /// </summary>
        private void BindData()
        {
            //定义变量
            string strSql, strTypeID, strKeyWords, strIsRecommend;

            //变量赋值
            strTypeID      = Request.QueryString["TypeID"];
            strKeyWords    = Request.QueryString["keyword"];
            strIsRecommend = Request.QueryString["IsRecommend"];

            //判断变量
            if (!FunctionClass.CheckStr(strTypeID, 1))
            {
                strTypeID = "1";
            }
            if (!FunctionClass.CheckStr(strIsRecommend, 1))
            {
                strIsRecommend = "";
            }

            //打开数据库
            DataClass     myData = new DataClass();
            SqlConnection myConn = myData.ConnOpen();

            //sql语句
            strSql = " where IsShow=1";
            if (strTypeID != "")
            {
                strSql += " and (" + myData.GetProTypeIDSql(strTypeID, myConn) + "TypeID=" + strTypeID + ")";
            }

            if (FunctionClass.CheckStr(strKeyWords, 0))
            {
                strSql += " and (ProName like '%" + strKeyWords.Replace("'", "''") + "%' or Content like '%" + strKeyWords.Replace("'", "''") + "%')";
            }

            if (strIsRecommend != "")
            {
                strSql += " and IsRecommend=" + strIsRecommend;
            }

            //初始化分页变量
            int intPageIndex       = FunctionClass.CurrentPage();
            int intPageSize        = 100;
            int intPageCount       = 0;
            int intPageRecordcount = 0;

            //创建Dataset对象读取数据记录集
            DataSet myDs = myData.GetDataSet("T_Products", strSql, "SID asc,NoteTime desc", intPageIndex, intPageSize,
                                             ref intPageCount, ref intPageRecordcount, myConn);

            DataView myDv = new DataView(myDs.Tables[0], "  ", "", DataViewRowState.CurrentRows);

            for (int i = 0; i < myDv.Count; i++)
            {
                lbList.Text += "<li><a href=" + FunctionClass.GetImgUrl(myDv[i]["Content"].ToString())
                               + " rel=\"lightbox-tour\" title=\"" + myDv[i]["ProName"].ToString()
                               + "\"><img src=\"" + FunctionClass.GetUploadFileRelativeURL(myDv[i]["ProPic"].ToString())
                               + "\" width=\"200\" height=\"133\" alt=\"" + myDv[i]["ProName"].ToString() + "\" /><br/>"
                               + myDv[i]["ProName"].ToString() + "</a></li>";
            }
            myDv.Dispose();

            //分页
            lbPageBar.Text = FunctionClass.GetPageBar(intPageIndex, intPageRecordcount, intPageCount, 4,
                                                      FunctionClass.GetNewURL("page", "{page}", FunctionClass.PageURL),
                                                      "<img src=\"images/news_19.jpg\" width=\"21\" height=\"13\" alt=\"第一页\" />",
                                                      "<img src=\"images/news_116.jpg\" width=\"21\" height=\"13\" alt=\"上一页\" />",
                                                      "<img src=\"images/news_22.jpg\" width=\"21\" height=\"13\" alt=\"下一页\" />",
                                                      "<img src=\"images/news_23.jpg\" width=\"21\" height=\"13\" alt=\"最后页\" />", false, false);
            myDs.Dispose();

            //分类名称赋值
            lbCalled.Text  = "美食推荐";
            lbCalled1.Text = "Food recommended";
            if (strTypeID == "")
            {
                hyCalled.Text        = "美食推荐";
                hyCalled.NavigateUrl = "products.aspx";
            }
            else
            {
                strSql = "select * from T_ProType where ID=" + strTypeID;
                SqlDataReader myDr = myData.GetSqlDataReader(strSql, myConn);
                if (myDr.Read())
                {
                    hyCalled.Text        = myDr["TypeCalled"].ToString();
                    hyCalled.NavigateUrl = "products.aspx?TypeID=" + strTypeID;
                    lbTypeCalled.Text    = myDr["TypeCalled"].ToString();
                    lbMemo.Text          = myDr["Memo"].ToString();;
                }
            }

            //关闭数据库
            myData.ConnClose(myConn);
        }
示例#14
0
文件: NewLog.cs 项目: lexzh/Myproject
 public override void addLogMsg(DataTable dtLogResult)
 {
     if ((dtLogResult != null) && (dtLogResult.Rows.Count != 0))
     {
         try
         {
             bool     flag = true;
             string   str  = null;
             DataView view = null;
             dtLogResult.Columns.Add(new DataColumn("ColLog"));
             dtLogResult.Columns.Add(new DataColumn("LocalCurTime"));
             view = new DataView(dtLogResult)
             {
                 RowFilter = base.m_dvLogData.RowFilter
             };
             int firstDisplayedScrollingRowIndex = base.dgvLogData.FirstDisplayedScrollingRowIndex;
             int count = view.Count;
             if (base.m_dvLogData.RowFilter.Length > 0)
             {
                 int length = dtLogResult.Select(base.m_dvLogData.RowFilter).Length;
             }
             this.execSetLaPlace(dtLogResult);
             if (base.m_dvLogData.Sort.Length == 0)
             {
                 base.m_dtLogData           = dtLogResult.Clone();
                 base.m_dvLogData           = new DataView(base.m_dtLogData, "", "LocalCurTime DESC,ReceTime DESC,OrderId DESC", DataViewRowState.CurrentRows);
                 base.dgvLogData.DataSource = base.m_dvLogData;
             }
             foreach (DataRow row in dtLogResult.Select(base.m_dvLogData.RowFilter))
             {
                 flag = true;
                 str  = row["OrderId"].ToString();
                 if (dtLogResult.Columns.IndexOf("RespCode") >= 0)
                 {
                     this.CancelAlarmResponse(row);
                 }
                 if (base.m_dtLogData.Rows.Count > 0)
                 {
                     if (((Convert.ToInt32(row["msgType"]) == CmdParam.OrderType.Command) || (Convert.ToInt32(row["msgType"]) == CmdParam.OrderType.SendMsg)) && ((row["OrderName"].ToString() != "末次位置查询") && (row["OrderName"].ToString() != "提示信息")))
                     {
                         string filterExpression = string.Format("OrderId='{0}'", str);
                         string str3             = "";
                         foreach (DataRow row2 in base.m_dtLogData.Select(filterExpression))
                         {
                             row2["OrderResult"] = row["OrderResult"];
                             row2["CommFlag"]    = row["CommFlag"];
                             str3 = row["Describe"].ToString().Trim();
                             if (str3.Length > 0)
                             {
                                 row2["Describe"] = str3;
                             }
                             flag = false;
                         }
                     }
                     else if ((Convert.ToInt32(row["msgType"]) == CmdParam.OrderType.Terminal) && ((row["OrderName"].ToString().Equals("设置多功能区域报警应答", StringComparison.OrdinalIgnoreCase) || row["OrderName"].ToString().Equals("设置车台分路段超速报警应答", StringComparison.OrdinalIgnoreCase)) || row["OrderName"].ToString().Equals("设置取消区域报警应答", StringComparison.OrdinalIgnoreCase)))
                     {
                         string str4 = string.Format("OrderId='{0}' and OrderName='{1}'", str, row["OrderName"].ToString());
                         string str5 = "";
                         foreach (DataRow row3 in base.m_dtLogData.Select(str4))
                         {
                             row3["OrderResult"] = row["OrderResult"];
                             row3["CommFlag"]    = row["CommFlag"];
                             str5 = row["Describe"].ToString().Trim();
                             if (str5.Length > 0)
                             {
                                 row3["Describe"] = str5;
                             }
                             flag = false;
                         }
                     }
                     this.BatchName(row, str);
                 }
                 if (flag)
                 {
                     int num2 = base.dgvLogData.SelectedRows.Count;
                     row["LocalCurTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                     base.m_dtLogData.ImportRow(row);
                     if (num2 == 0)
                     {
                         base.dgvLogData.ClearSelection();
                     }
                     if (base.m_dtLogData.Rows.Count > base.iMaxLogCnt)
                     {
                         base.m_dvLogData.Delete(base.iMaxLogCnt);
                     }
                 }
             }
             str = null;
             if (firstDisplayedScrollingRowIndex >= 0)
             {
                 base.dgvLogData.FirstDisplayedScrollingRowIndex = firstDisplayedScrollingRowIndex;
             }
             base.dgvLogData.Refresh();
             view.Dispose();
             view = null;
         }
         catch (Exception exception)
         {
             if (Variable.bLogin)
             {
                 Record.execFileRecord("最新日志添加操作", exception.Message);
             }
         }
         finally
         {
             if (dtLogResult != null)
             {
                 dtLogResult = null;
             }
         }
     }
 }
示例#15
0
 public override void addLogMsg(DataTable dtLogResult)
 {
     if ((dtLogResult == null) || (dtLogResult.Rows.Count == 0))
     {
         base.txtNewLogCnt2.Text = "0";
     }
     else
     {
         DataView dv = null;
         try
         {
             dtLogResult.Columns.Add(new DataColumn("ColLog"));
             dv = new DataView(dtLogResult)
             {
                 RowFilter = base.m_dvLogData.RowFilter
             };
             int firstDisplayedScrollingRowIndex = base.dgvLogData.FirstDisplayedScrollingRowIndex;
             int count = dv.Count;
             if (base.m_dvLogData.Sort.Length == 0)
             {
                 base.m_dtLogData = dtLogResult.Clone();
                 if (Variable.sShowTogether.Equals("0"))
                 {
                     base.m_dvLogData = new DataView(base.m_dtLogData, "", "ReceTime DESC", DataViewRowState.CurrentRows);
                 }
                 else
                 {
                     dtLogResult.PrimaryKey = new DataColumn[] { dtLogResult.Columns["CarId"] };
                     base.m_dtLogData       = dtLogResult.Clone();
                     base.m_dvLogData       = new DataView(base.m_dtLogData, "", "CarNum", DataViewRowState.CurrentRows);
                 }
                 base.dgvLogData.DataSource = base.m_dvLogData;
             }
             if (Variable.sShowTogether.Equals("0"))
             {
                 this.addData(count, firstDisplayedScrollingRowIndex, dv);
             }
             else
             {
                 foreach (DataRow row in dtLogResult.Rows)
                 {
                     string key = row["CarId"].ToString();
                     if (base.m_dtLogData.Rows.Contains(key))
                     {
                         this.updateData(row);
                     }
                     else
                     {
                         base.m_dtLogData.Rows.Add(row.ItemArray);
                     }
                 }
                 base.m_dvLogData = new DataView(base.m_dtLogData, "", "CarNum", DataViewRowState.CurrentRows);
             }
             dv.Dispose();
             dv = null;
         }
         catch (Exception exception)
         {
             if (Variable.bLogin)
             {
                 Record.execFileRecord("最新位置日志添加操作", exception.Message);
             }
         }
     }
 }
示例#16
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataGridViewRowCollection drc = dataGridView1.Rows;
            DataGridViewRow           dr  = drc[dataGridView1.CurrentCellAddress.Y];

            // Получение общей суммы платежей абонента
            // Получение значения логина для выбранной строки в Customers
            string login = dr.Cells[1].Value.ToString();
            // Получение представления таблицы Payments
            DataView payments = new DataView(dataSet1.Tables["Payments"]);

            // Установка фильтра для отбора тех значений, которые относятся к нашему абоненту
            payments.RowFilter = "customer = '" + login + "'";
            // Посчет суммы платежей нашего абонента
            double sum = 0;

            foreach (DataRowView dRow in payments)
            {
                sum += Convert.ToDouble(dRow["the_sum"].ToString());
            }

            /*
             * Аналогичный запрос на sql выглядел бы так:
             * select sum(the_summ)
             * from Payments
             * where :login = customer
             * Результат запишем в переменную sum
             */

            // Получение суммы длительностей разговоров
            // Получение представления таблицы Phones
            DataView phones = new DataView(dataSet1.Tables["Phones"]);

            // Получение номера телефона, который зарегистрирован за нашим абонентом
            phones.RowFilter = "cid = '" + login + "'";
            // Если его нет - то ошибка
            if (phones.Count == 0)
            {
                MessageBox.Show("Ошибка. У абонента " + login + " не зарегистрирован телефон.");
                return;
            }
            string phone = phones[0].Row["phone"].ToString();
            // Получение представления таблицы Calls
            DataView calls = new DataView(dataSet1.Tables["Calls"]);

            // Оставление звонков с найденным номером
            calls.RowFilter = "the_number = '" + phone + "'";
            // Подсчет общего количества проговоренных минут
            double sumDuration = 0;

            foreach (DataRowView dRow in calls)
            {
                sumDuration += Convert.ToDouble(dRow["duration"].ToString());
            }
            // Если наш абонент владеет транком, то сумма будет нулем, в этом случае
            // ищем сумму разговоров через таблицу Trunks
            if (sumDuration == 0)
            {
                // Получение представления таблицы Trunks
                DataView trunks = new DataView(dataSet1.Tables["Trunks"]);
                // Получение номера телефона, который зарегистрирован за нашим абонентом
                trunks.RowFilter = "customer = '" + login + "'";
                // Если у нашего абонента нет транка, то sumDuration не пересчитывается
                // (возможно он еще вообще не звонил)
                if (trunks.Count == 0)
                {
                    goto ex;
                }
                int trunk = Convert.ToInt32(trunks[0].Row["trunk"].ToString());
                // Оставление звонков с найденным номером
                calls.RowFilter = "trunk = " + trunk.ToString();
                // Подсчет общего количества проговоренных минут
                sumDuration = 0;
                foreach (DataRowView dRow in calls)
                {
                    sumDuration += Convert.ToDouble(dRow["duration"].ToString());
                }
                trunks.Dispose();
            }
ex:

            /*
             * Аналогичный запрос на sql выглядел бы так:
             * select sum(c.duration)
             * from Calls c, Phones ph
             * where :login = ph.cid && c.the_number = ph.phone
             *
             *
             * select sum(c.duration)
             * from Calls c, Trunks t
             * where :login = t.customer && t.trunk = c.trunk
             * Результатом будет наибольшая из сумм
             * Запишем ее в переменную sumDuration
             */

            // Получение стоимости минуты разговора
            // Получение кода тарифа нашего абонента
            int code = Convert.ToInt32(dr.Cells[7].Value.ToString());
            // Получение представления таблицы Tarif
            DataView tarifs = new DataView(dataSet1.Tables["Tarif"]);

            //  Оставление записи с указанным кодом
            tarifs.RowFilter = "code = " + code.ToString();
            // Получение стоимости минуты разговора
            double cost = Convert.ToDouble(tarifs[0].Row["cost"].ToString());

            /*
             * Аналогичный запрос на sql выглядел бы так:
             * select cost
             * from Tarif
             * where :tarif_id = code
             * Результат запишем в переменную cost
             */

            // Получение налога
            // Получение кода тарифа нашего абонента
            int tax = Convert.ToInt32(dr.Cells[4].Value.ToString());
            // Получение представления таблицы Tarif
            DataView taxs = new DataView(dataSet1.Tables["Tax"]);

            //  Оставление записи с указанным кодом
            taxs.RowFilter = "code = " + tax.ToString();
            // Получение стоимости минуты разговора
            double tax_value = Convert.ToDouble(taxs[0].Row["tax_value"].ToString());

            /*
             * Аналогичный запрос на sql выглядел бы так:
             * select tax_value
             * from Tax
             * where :tax = code
             * Результат запишем в переменную tax
             */

            // Установка нового баланса (из суммы внесенных средств вычитается налог)
            dr.Cells[3].Value = sum - (sum * tax_value / 100) - sumDuration * cost;

            phones.Dispose();
            tarifs.Dispose();
            calls.Dispose();
            taxs.Dispose();
            payments.Dispose();
        }
示例#17
0
    private void Init_Form()
    {
        txtcountryno.Attributes.Add("onkeyup", "chkPostiveInteger('" + txtcountryno.ClientID + "')");
        txtcountryno.Attributes.Add("onblur", "chkPostiveInteger('" + txtcountryno.ClientID + "')");

        txtLPTF.Attributes.Add("onkeyup", "chkPostiveInteger('" + txtLPTF.ClientID + "')");
        txtLPTF.Attributes.Add("onblur", "chkPostiveInteger('" + txtLPTF.ClientID + "')");

        txtSatelliteID.Attributes.Add("onkeyup", "chkPostiveInteger('" + txtSatelliteID.ClientID + "')");
        txtSatelliteID.Attributes.Add("onblur", "chkPostiveInteger('" + txtSatelliteID.ClientID + "')");
        txtNationalId.Attributes.Add("onKeyup", "chkNumeric('" + txtNationalId.ClientID + "')");

        txtfacilityname.Text      = "";
        txtcountryno.Text         = "";
        txtLPTF.Text              = "";
        txtSatelliteID.Text       = "";
        txtGrace.Text             = "";
        txtPEPFAR_Fund.Text       = "";
        cmbCurrency.SelectedValue = "0";
        if (Session["SystemId"].ToString() == "2")
        {
            paperless.Visible = false;
        }
        //BindCombo();
        //ddBackupTime.SelectedValue = "0";


        BindFunctions BindManager = new BindFunctions();
        IQCareUtils   theUtils    = new IQCareUtils();
        DataSet       theDSXML    = new DataSet();

        theDSXML.ReadXml(MapPath("..\\XMLFiles\\AllMasters.con"));

        DataView  theDV = new DataView();
        DataTable theDT = new DataTable();

        /*******/
        theDV           = new DataView(theDSXML.Tables["Mst_District"]);
        theDV.RowFilter = "DeleteFlag=0 and SystemID= " + Session["SystemId"] + "";
        if (theDV.Table != null)
        {
            theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
            BindManager.BindCombo(ddldistrict, theDT, "Name", "ID");
            theDV.Dispose();
            theDT.Clear();
        }

        theDV           = new DataView(theDSXML.Tables["Mst_Province"]);
        theDV.RowFilter = "Deleteflag=0 and SystemID=" + Session["SystemId"] + "";
        if (theDV.Table != null)
        {
            theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
            BindManager.BindCombo(ddlprovince, theDT, "Name", "ID");
            theDV.Dispose();
            theDT.Clear();
        }
        /////////////////////////////////////////////////
        IFacilitySetup FacilityManager = (IFacilitySetup)ObjectFactory.CreateInstance("BusinessProcess.Administration.BFacility, BusinessProcess.Administration");
        DataSet        theDSFacility   = FacilityManager.GetModuleName();
        DataTable      DT = theDSFacility.Tables[0];

        BindManager.BindCheckedList(cblPMTCT, DT, "modulename", "moduleid");
    }
    private void BindGrid()
    {
        if (ViewState["Sorted"] != null)
        {
            IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
            DataSet          theDS = PatientTransferMgr.GetSatelliteLocation(PatientId, TransferId, 0, Session["SystemId"].ToString());
            txtLocationName.Text = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
            BindFunctions BindManager = new BindFunctions();
            IQCareUtils   theUtils    = new IQCareUtils();
            DataView      theDV       = new DataView(theDS.Tables[1]);
            DataTable     theDT       = new DataTable();
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddSatellite, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }
            GrdTransfer.DataSource = theDS.Tables[2];
            if (ViewState["grdDataSource"] == null)
            {
                ViewState["grdDataSource"] = theDS.Tables[2];
            }
        }

        ViewState["Sorted"] = "";
        BoundField theCol0 = new BoundField();

        theCol0.HeaderText           = "ID";
        theCol0.DataField            = "ID";
        theCol0.HeaderStyle.CssClass = "textstylehidden";
        theCol0.ItemStyle.CssClass   = "textstylehidden";
        theCol0.ReadOnly             = true;

        BoundField theCol1 = new BoundField();

        theCol1.HeaderText         = "From Location";
        theCol1.DataField          = "TransferfromSatellite";
        theCol1.ItemStyle.CssClass = "textstyle";
        theCol1.SortExpression     = "TransferfromSatellite";
        theCol1.ReadOnly           = true;

        BoundField theCol2 = new BoundField();

        theCol2.HeaderText         = "To Location";
        theCol2.DataField          = "TransfertoSatellite";
        theCol2.ItemStyle.CssClass = "textstyle";
        theCol2.SortExpression     = "TransfertoSatellite";
        theCol2.ReadOnly           = true;

        BoundField theCol3 = new BoundField();

        theCol3.HeaderText         = "Transferred Date";
        theCol3.DataField          = "TransferredDate";
        theCol3.ItemStyle.CssClass = "textstyle";
        theCol3.SortExpression     = "TransferredDate";
        theCol3.ReadOnly           = true;

        ButtonField theBtn = new ButtonField();

        theBtn.ButtonType           = ButtonType.Link;
        theBtn.CommandName          = "Select";
        theBtn.HeaderStyle.CssClass = "textstylehidden";
        theBtn.ItemStyle.CssClass   = "textstylehidden";

        GrdTransfer.Columns.Add(theCol0);
        GrdTransfer.Columns.Add(theCol1);
        GrdTransfer.Columns.Add(theCol2);
        GrdTransfer.Columns.Add(theCol3);
        GrdTransfer.Columns.Add(theBtn);
        GrdTransfer.DataBind();
    }
示例#19
0
        //Ejecuta el query y retorna datos en el tipo que se requiera
        public object Query(string strSQL, TipoDato eTipoDato)
        {
            object    query   = new object();
            DataSet   dtsTemp = new DataSet();
            DataTable dttTemp = new DataTable();
            DataView  dtvTemp = new DataView();

            switch (motorBD)
            {
            case "SqlServer":
                SqlConnection  cnConexionSQL   = new SqlConnection(mstrConnectionStringMSSQL);
                SqlCommand     cmComandoSQL    = new SqlCommand(strSQL, cnConexionSQL);
                SqlDataAdapter dtaAdaptadorSQL = new SqlDataAdapter();
                SqlDataReader  dtrTempSQL;

                cnConexionSQL.Open();
                cmComandoSQL.CommandType      = CommandType.Text;
                dtaAdaptadorSQL.SelectCommand = cmComandoSQL;

                switch (eTipoDato)
                {
                case TipoDato.DataSet:
                    dtaAdaptadorSQL.Fill(dtsTemp, "Temp");
                    query = dtsTemp;
                    break;

                case TipoDato.Table:
                    dtaAdaptadorSQL.Fill(dttTemp);
                    query = dttTemp;
                    break;

                case TipoDato.View:
                    dtaAdaptadorSQL.Fill(dttTemp);
                    dttTemp.TableName = "Temp";
                    dtvTemp.Table     = dttTemp;
                    query             = dtvTemp;
                    break;

                case TipoDato.RecordSet:
                    dtrTempSQL = cmComandoSQL.ExecuteReader();
                    query      = dtrTempSQL;
                    break;
                }

                cnConexionSQL.Close();
                cnConexionSQL.Dispose();
                cmComandoSQL.Dispose();
                dtaAdaptadorSQL.Dispose();
                dtrTempSQL = null;
                break;

            case "Oracle":
                OracleConnection cnConexion = new OracleConnection(mstrConnectionStringORACLE);

                OracleCommand     cmComandoORA    = new OracleCommand(strSQL, cnConexion);
                OracleDataAdapter dtaAdaptadorORA = new OracleDataAdapter();
                OracleDataReader  dtrTempORA;

                cnConexion.Open();

                OracleGlobalization SessionGlob = cnConexion.GetSessionInfo();
                SessionGlob.NumericCharacters = ",.";
                SessionGlob.DateFormat        = "dd/mm/yyyy";
                cnConexion.SetSessionInfo(SessionGlob);

                cmComandoORA.CommandType      = CommandType.Text;
                dtaAdaptadorORA.SelectCommand = cmComandoORA;

                switch (eTipoDato)
                {
                case TipoDato.DataSet:
                    dtaAdaptadorORA.Fill(dtsTemp, "Temp");
                    query = dtsTemp;
                    break;

                case TipoDato.Table:
                    dtaAdaptadorORA.Fill(dttTemp);
                    query = dttTemp;
                    break;

                case TipoDato.View:
                    dtaAdaptadorORA.Fill(dttTemp);
                    dttTemp.TableName = "Temp";
                    dtvTemp.Table     = dttTemp;
                    query             = dtvTemp;
                    break;

                case TipoDato.RecordSet:
                    dtrTempORA = cmComandoORA.ExecuteReader();
                    query      = dtrTempORA;
                    break;
                }

                cnConexion.Close();
                cnConexion.Dispose();
                cmComandoORA.Dispose();
                dtaAdaptadorORA.Dispose();
                dtrTempORA = null;
                break;

            case "ODBC":

                OdbcConnection  cnConexionOdbc   = new OdbcConnection(mstrConnectionStringODBC);
                OdbcCommand     cmComandoOdbc    = new OdbcCommand(strSQL, cnConexionOdbc);
                OdbcDataAdapter dtaAdaptadorOdbc = new OdbcDataAdapter();
                OdbcDataReader  dtrTempOdbc;

                cnConexionOdbc.Open();

                cmComandoOdbc.CommandType      = CommandType.Text;
                dtaAdaptadorOdbc.SelectCommand = cmComandoOdbc;

                switch (eTipoDato)
                {
                case TipoDato.DataSet:
                    dtaAdaptadorOdbc.Fill(dtsTemp, "Temp");
                    query = dtsTemp;
                    break;

                case TipoDato.Table:
                    dtaAdaptadorOdbc.Fill(dttTemp);
                    query = dttTemp;
                    break;

                case TipoDato.View:
                    dtaAdaptadorOdbc.Fill(dttTemp);
                    dttTemp.TableName = "Temp";
                    dtvTemp.Table     = dttTemp;
                    query             = dtvTemp;
                    break;

                case TipoDato.RecordSet:
                    dtrTempOdbc = cmComandoOdbc.ExecuteReader();
                    query       = dtrTempOdbc;
                    break;
                }

                cnConexionOdbc.Close();
                cnConexionOdbc.Dispose();
                cmComandoOdbc.Dispose();
                dtaAdaptadorOdbc.Dispose();
                dtrTempORA = null;
                break;
            }

            dtsTemp.Dispose();
            dttTemp.Dispose();
            dtvTemp.Dispose();
            return(query);
        }
示例#20
0
        private void backgroundWorkerDoCommand_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker  = sender as BackgroundWorker;
            DataView         rundata = new DataView();

            rundata = dtom3.ConvertToGCode(dataGridView1, Double.Parse(ribbonTextBoxBoardOffsetX.TextBoxText), Double.Parse(ribbonTextBoxBoardOffsetY.TextBoxText));

            RunMach3Command(Script, "F" + FeedRate.ToString());
            int currentrow = 0;
            int totalrows  = rundata.Count;

            if (totalrows > 0)
            {
                // MessageBox.Show(totalrows.ToString());
                RunMach3Command(Script, "G01 B0 C0");

                /* table columns
                 * RefDes
                 *  Type
                 *  PosX
                 *  PosY
                 *  ComponentRotation
                 *  ComponentValue
                 *  feederNumber
                 *  Code
                 *
                 *
                 *  ComponentHeight
                 *  DefaultRotation
                 *  VerifywithCamera
                 *  TapeFeeder
                 *
                 *
                 *  feederPosX
                 *  feederPosY
                 *  feederPosZ
                 *  PickPlusChipHeight
                 * */

                double progresspert     = 0;
                double progresspertcalc = 100 / totalrows;
                while (currentrow < totalrows)
                {
                    if (backgroundWorkerDoCommand.CancellationPending)
                    {
                        e.Cancel = true;
                        SetCurrentCommandText("Stopped");


                        rundata.Dispose();
                        break;
                    }

                    if (currentrow == 0)
                    {
                        SetFeederOutputs(Int32.Parse(rundata[currentrow]["FeederNumber"].ToString())); // send feeder to position
                    }
                    SetCurrentCommandText("Feeder Activate");
                    SetCurrentCommandText(rundata[currentrow]["RefDes"].ToString());
                    StetActiveComponentText(rundata[currentrow]["RefDes"].ToString());



                    if (!rundata[currentrow]["TapeFeeder"].ToString().Equals("True"))
                    {
                        RunMach3Command(Script, "G01 A" + CalcAZHeight(ClearHeight));
                    }
                    RunMach3Command(Script, "G01 X" + rundata[currentrow]["feederPosX"].ToString() + "  Y" + rundata[currentrow]["feederPosY"].ToString());

                    SetCurrentCommandText("Picking Component");
                    if (rundata[currentrow]["TapeFeeder"].ToString().Equals("True"))
                    {
                        // use picker 1
                        RunMach3Command(Script, "G01 A" + CalcAZHeight(Double.Parse(rundata[currentrow]["feederPosZ"].ToString()))); // go down and turn on suction
                        ChangeVacOutput(1, true);
                        RunMach3Command(Script, "G01 A" + CalcAZHeight(LowClearHeight));
                    }
                    else
                    {
                        // use picker 2


                        RunMach3Command(Script, "G01 Z" + CalcAZHeight(Double.Parse(rundata[currentrow]["feederPosZ"].ToString()))); // go down and turn on suction
                        ChangeVacOutput(2, true);
                        //Thread.Sleep(500);
                        RunMach3Command(Script, "G01 Z" + CalcAZHeight(ClearHeight));
                    }
                    // send picker to pick next item
                    if (currentrow >= 0 && (currentrow + 1) < totalrows)
                    {
                        SetFeederOutputs(Int32.Parse(rundata[currentrow + 1]["FeederNumber"].ToString())); // send feeder to position
                    }

                    // rotate head
                    double ComponentRotation = Double.Parse(rundata[currentrow]["ComponentRotation"].ToString());
                    double DefaultRotation   = Double.Parse(rundata[currentrow]["DefaultRotation"].ToString());



                    RunMach3Command(Script, "G92 B0 C0 ");
                    SetResultsLabelText("Placing Component");
                    if (rundata[currentrow]["TapeFeeder"].ToString().Equals("True"))
                    {
                        // use picker 1
                        if (DefaultRotation != ComponentRotation)
                        {
                            double newrotation = DefaultRotation + ComponentRotation;
                            RunMach3Command(Script, "G01 B" + newrotation.ToString() + " X" + rundata[currentrow]["PosX"].ToString() + "  Y" + rundata[currentrow]["PosY"].ToString());
                        }
                        else
                        {
                            RunMach3Command(Script, "G01 X" + rundata[currentrow]["PosX"].ToString() + "  Y" + rundata[currentrow]["PosY"].ToString());
                        }
                        RunMach3Command(Script, "G01 A" + CalcAZPlaceHeight(Double.Parse(rundata[currentrow]["ComponentHeight"].ToString()))); // go down and turn off suction
                        ChangeVacOutput(1, false);
                        RunMach3Command(Script, "G01 A" + CalcAZHeight(LowClearHeight));
                    }
                    else
                    {
                        // use picker 2  CalcXwithNeedleSpacing
                        if (DefaultRotation != ComponentRotation)
                        {
                            double newrotation = DefaultRotation + ComponentRotation;
                            RunMach3Command(Script, "G01 C" + newrotation.ToString() + " X" + CalcXwithNeedleSpacing(Double.Parse(rundata[currentrow]["PosX"].ToString())).ToString() + "  Y" + rundata[currentrow]["PosY"].ToString());
                        }
                        else
                        {
                            RunMach3Command(Script, "G01 X" + CalcXwithNeedleSpacing(Double.Parse(rundata[currentrow]["PosX"].ToString())).ToString() + "  Y" + rundata[currentrow]["PosY"].ToString());
                        }
                        RunMach3Command(Script, "G01 Z" + CalcAZPlaceHeight(Double.Parse(rundata[currentrow]["ComponentHeight"].ToString()))); // go down and turn off suction
                        ChangeVacOutput(2, false);
                        RunMach3Command(Script, "G01 Z" + CalcAZHeight(ClearHeight));
                    }



                    currentrow++;
                    progresspert = currentrow * progresspertcalc;
                    worker.ReportProgress(Int32.Parse(progresspert.ToString()));
                }
                rundata.Dispose();
                // home all axis and zero
                SetResultsLabelText("Home and Reset");
                RunMach3Command(Script, "G92 B0 C0 ");

                Thread thrd = new Thread(new ThreadStart(DoHomeAll));
                thrd.Start();
                thrd.IsBackground = true;
            }
            else
            {
                MessageBox.Show("Board file not loaded");
            }
            backgroundWorkerDoCommand.CancelAsync();

            worker.ReportProgress(100);
        }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            if (lstAvailable.SelectedIndex >= 0)
            {
                BindFunctions BindManager = new BindFunctions();
                IQCareUtils   theUtils    = new IQCareUtils();

                if (Request.QueryString["Type"] == "Strength")
                {
                    DataRow   theDR;
                    DataTable theDTAvail = (DataTable)ViewState["MasterTable"];

                    DataTable theDTSel = (DataTable)ViewState["SelectedData"];

                    DataView theDV = new DataView(theDTAvail);
                    theDV.RowFilter = "StrengthId =" + lstAvailable.SelectedValue;
                    theDR           = theDTSel.NewRow();
                    theDR[0]        = Convert.ToInt32(theDV[0][0]);
                    theDR[1]        = theDV[0][1].ToString();
                    theDTSel.Rows.Add(theDR);
                    lstSelected.DataSource = theDTSel;
                    lstSelected.DataBind();
                    ViewState["SelectedData"] = theDTSel;

                    DataRow[] theDR1 = theDTAvail.Select("StrengthId='" + lstAvailable.SelectedValue + "'");
                    theDTAvail.Rows.Remove(theDR1[0]);
                    lstAvailable.DataSource = theDTAvail;
                    lstAvailable.DataBind();
                    ViewState["MasterTable"] = theDTAvail;
                }
                else if (Request.QueryString["Type"] == "Frequency")
                {
                    DataRow   theDR;
                    DataTable theDTAvail = (DataTable)ViewState["MasterTable"];

                    DataTable theDTSel = (DataTable)ViewState["SelectedData"];

                    DataView theDV = new DataView(theDTAvail);
                    theDV.RowFilter = "Id =" + lstAvailable.SelectedValue;
                    theDR           = theDTSel.NewRow();
                    theDR[0]        = Convert.ToInt32(theDV[0][0]);             ////(lstAvailable.SelectedValue);
                    theDR[1]        = theDV[0][1].ToString();
                    theDTSel.Rows.Add(theDR);
                    lstSelected.DataSource = theDTSel;
                    lstSelected.DataBind();
                    ViewState["SelectedData"] = theDTSel;

                    theDR = null;
                    theDV.Dispose();
                    // theDR[2] = "";
                    /////lstAvailable.SelectedItem.Text;

                    DataRow[] theDR1;
                    theDR1 = theDTAvail.Select("Id='" + lstAvailable.SelectedValue + "'");
                    theDTAvail.Rows.Remove(theDR1[0]);
                    lstAvailable.DataSource = theDTAvail;
                    lstAvailable.DataBind();
                    ViewState["MasterTable"] = theDTAvail;
                }
                else if (Request.QueryString["Type"] == "Schedule")
                {
                    DataRow   theDR;
                    DataTable theDTAvail = (DataTable)ViewState["MasterTable"];

                    DataTable theDTSel = (DataTable)ViewState["SelectedData"];

                    DataView theDV = new DataView(theDTAvail);
                    theDV.RowFilter = "Id =" + lstAvailable.SelectedValue;
                    theDR           = theDTSel.NewRow();
                    theDR[0]        = Convert.ToInt32(theDV[0][0]);             ////(lstAvailable.SelectedValue);
                    theDR[1]        = theDV[0][1].ToString();
                    theDTSel.Rows.Add(theDR);
                    lstSelected.DataSource = theDTSel;
                    lstSelected.DataBind();
                    ViewState["SelectedData"] = theDTSel;

                    theDR = null;
                    theDV.Dispose();
                    // theDR[2] = "";
                    /////lstAvailable.SelectedItem.Text;

                    DataRow[] theDR1;
                    theDR1 = theDTAvail.Select("Id='" + lstAvailable.SelectedValue + "'");
                    theDTAvail.Rows.Remove(theDR1[0]);
                    lstAvailable.DataSource = theDTAvail;
                    lstAvailable.DataBind();
                    ViewState["MasterTable"] = theDTAvail;
                }
                else
                {
                    DataRow   theDR;
                    DataTable theDTAvail = (DataTable)ViewState["MasterTable"];

                    //if (ViewState["DrugStrengthSel"] != null)
                    //{
                    DataTable theDTSel = (DataTable)ViewState["SelectedData"];

                    DataView theDV = new DataView(theDTAvail);
                    theDV.RowFilter = "GenericId =" + lstAvailable.SelectedValue;
                    theDR           = theDTSel.NewRow();
                    theDR[0]        = Convert.ToInt32(theDV[0][0]);             ////(lstAvailable.SelectedValue);
                    theDR[1]        = theDV[0][1].ToString();
                    theDR[2]        = theDV[0]["GenericAbbrevation"];
                    /////lstAvailable.SelectedItem.Text;
                    theDTSel.Rows.Add(theDR);
                    lstSelected.DataSource = theDTSel;
                    lstSelected.DataBind();
                    ViewState["SelectedData"] = theDTSel;

                    DataRow[] theDR1 = theDTAvail.Select("GenericId=" + lstAvailable.SelectedValue);
                    theDTAvail.Rows.Remove(theDR1[0]);
                    lstAvailable.DataSource = theDTAvail;
                    lstAvailable.DataBind();
                    ViewState["MasterTable"] = theDTAvail;
                }
            }
            else
            {
                IQCareMsgBox.Show("NoItemToAdd", this);
            }
        }
        catch (Exception err)
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["MessageText"] = err.Message.ToString();
            IQCareMsgBox.Show("#C1", theBuilder, this);
        }
    }
    //int VisitID;
    #region "User Functions"
    //int currentDate;
    #region "Modified13June07(1)"
    private void fillDropDownList(int idPurpose, int idEmployee)


    {
        ////*******Get the patient details on the basis of Patient Enrollment Id and show the details.*******//
        //FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");
        ////DataSet theDtSet = FormManager.GetEmployees(idEmployee);

        //appBind = new BindFunctions();
        //appBind.BindCombo(ddAppProvider, theDtSet.Tables[0],"EmployeeName", "EmployeeId" );

        ////DataSet theDtSetPurpose = FormManager.GetAppointmentReasons(idPurpose);
        //appBind = new BindFunctions();
        //appBind.BindCombo(ddAppPurpose, theDtSetPurpose.Tables[0], "Name", "Id");

        //{
        IAppointment FormManager;

        FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");
        DataSet       theDtSet        = FormManager.GetEmployees(idEmployee);
        DataSet       theDtSetPurpose = FormManager.GetAppointmentReasons(idPurpose);
        BindFunctions appBind         = new BindFunctions();
        IQCareUtils   theUtils        = new IQCareUtils();

        if (Request.QueryString["Name"] == "Add")
        {
            //if (Convert.ToInt32(Session["PatientVisitId"]) == 0)
            //{
            DataView theDV = new DataView(theDtSet.Tables[0]);
            DataView TheDV = new DataView(theDtSetPurpose.Tables[0]);
            theDV.RowFilter = "DeleteFlag=0";
            TheDV.RowFilter = "DeleteFlag=0";
            DataTable DT = (DataTable)theUtils.CreateTableFromDataView(theDV);
            if (Convert.ToInt32(Session["AppUserEmployeeId"]) > 0)
            {
                theDV           = new DataView(DT);
                theDV.RowFilter = "EmployeeId =" + Session["AppUserEmployeeId"].ToString();
                if (theDV.Count > 0)
                {
                    DT = theUtils.CreateTableFromDataView(theDV);
                }
            }
            DataTable TheDT = (DataTable)theUtils.CreateTableFromDataView(TheDV);
            appBind.BindCombo(ddAppProvider, DT, "EmployeeName", "EmployeeId");
            appBind.BindCombo(ddAppPurpose, TheDT, "Name", "Id");
            theDV.Dispose();
            TheDV.Dispose();
            DT.Clear();
            TheDT.Clear();
        }



        //}


        else if (Request.QueryString["name"] == "Edit" || Request.QueryString["name"] == "Delete")

        {
            BindDropdownOrderBy(theDtSet.Tables[0].Rows[0]["EmployeeName"].ToString());
            this.ddAppProvider.SelectedValue = theDtSet.Tables[0].Rows[0]["EmployeeName"].ToString();

            //appBind.BindCombo(ddAppProvider, theDtSet.Tables[0], "EmployeeName", "EmployeeId");
            appBind.BindCombo(ddAppPurpose, theDtSetPurpose.Tables[0], "Name", "Id");
        }
    }
示例#23
0
        private void montaGraficoPieChart()
        {
            //Busca Informações
            DataTable dataTable = funcoes.CSVtoTable(10);

            //Ordena pela Coluna Desejada
            EnumerableRowCollection <DataRow> query = from order in dataTable.AsEnumerable()
                                                      orderby order.Field <decimal>("Preço de venda") descending
                                                      select order;

            //Escolha quais colunas devem ir pro Grid
            string[]  selectedColumns = new[] { "Código", "Produto", "Preço de venda" };
            DataTable dt = new DataView(dataTable).ToTable(false, selectedColumns);

            gvProdutos.DataSource = dt;
            gvProdutos.DataBind();



            //DataTable dt = new DataTable();
            //dt = lerCSV();
            StringBuilder strScript = new StringBuilder();

            if (dt.Rows.Count > 0)
            {
                try
                {
                    strScript.Append(@"<script type='text/javascript'>  
                                       google.charts.load('current', {'packages':['corechart']});
                                       google.charts.setOnLoadCallback(drawChart);

                                       function drawChart() {
                                         var data = google.visualization.arrayToDataTable([
                                         ['Produto', 'R$ Vendas'],");

                    foreach (DataRow row in dt.Rows)
                    {
                        strScript.Append("['" + row["Produto"] + "'," + row["Preço de venda"] + "],");
                    }

                    strScript.Remove(strScript.Length - 1, 1);
                    strScript.Append("]);");

                    //strScript.Append("var options = {legend: {position: 'none'}, vAxis: { format: '0.0' }};");

                    strScript.Append("var options = {          title: 'Produtos mais Vendidos (Valor)'        }; ");

                    strScript.Append("var chart = new google.visualization.PieChart(document.getElementById('curve_chart')); chart.draw(data, options);}</script><div id='curve_chart' style='width: 700px; height: 400px'></div>");

                    ltScripts.Text = strScript.ToString();
                }
                catch
                {
                }
                finally
                {
                    dt.Dispose();
                    strScript.Clear();
                }
            }
            else
            {
                ltScripts.Text = "<div class=''><br/><div style='margin: 5px'><div class='titulo-box' style='margin-left: 15px'>Não existem mudanças Cadastradas.</div></div></div><br/>";
            }
        }
示例#24
0
        protected void CheckBT_Click(object sender, EventArgs e)
        {
            if ((upload_file.PostedFile != null) && (upload_file.PostedFile.ContentLength > 0))
            {
                string fileName      = System.IO.Path.GetFileName(upload_file.PostedFile.FileName);
                string LocationFiled = Server.MapPath(Str上傳路徑);
                string str頁簽名稱       = "";

                try
                {
                    DataTable         D_table      = new DataTable("Excel");
                    DataTable         D_errortable = new DataTable("Error");
                    DataTable         DtCula       = new DataTable("CulTable");
                    List <ColorClass> colorClasses = new List <ColorClass>();

                    string 副檔名 = System.IO.Path.GetExtension(fileName);
                    if (Session["DataDefine"] != null)
                    {
                        Session.Remove("DataDeffine");
                    }
                    int I資料起始列;

                    #region 基本資料欄位

                    #endregion

                    #region ErrorTable
                    //D_errortable.Columns.Add("SheetName");
                    //D_errortable.Columns.Add("Dept");
                    D_errortable.Columns.Add("Error");
                    #endregion
                    //
                    //foreach (DataRow Dr in DtColumnDefine.Rows)
                    //{
                    //    D_table.Columns.Add(Dr["資料名稱中文"].ToString());
                    //}

                    I資料起始列 = 0;

                    while (File.Exists(LocationFiled + fileName))
                    {
                        fileName = fileName.Substring(0, fileName.Length - 副檔名.Length) + DateTime.Now.ToString("yyyyMMddhhmmssfff") + 副檔名;
                    }
                    upload_file.PostedFile.SaveAs(LocationFiled + fileName);

                    if (副檔名.ToUpper() == ".XLSX")
                    {
                        XSSFWorkbook workbook = new XSSFWorkbook(upload_file.PostedFile.InputStream);  //==只能讀取 System.IO.Stream
                        for (int x = 0; x < workbook.NumberOfSheets; x++)
                        {
                            //-- 0表示:第一個 worksheet工作表
                            XSSFSheet u_sheet = (XSSFSheet)workbook.GetSheetAt(x);
                            str頁簽名稱 = u_sheet.SheetName.ToString();
                            //-- Excel 表頭列
                            XSSFRow headerRow = (XSSFRow)u_sheet.GetRow(I資料起始列);
                            IRow    DateRow   = (IRow)u_sheet.GetRow(I資料起始列);
                            //i=1第二列開始
                            for (int i = I資料起始列; i <= u_sheet.LastRowNum; i++)
                            {
                                //--不包含 Excel表頭列的 "其他資料列"
                                IRow row = (IRow)u_sheet.GetRow(i);
                                F_資料確認(ref D_table, ref D_errortable, ref DtCula, row, i, ref colorClasses);
                            }
                            //-- 釋放 NPOI的資源
                            u_sheet = null;
                        }
                        //-- 釋放 NPOI的資源
                        workbook = null;
                    }
                    else
                    {
                        HSSFWorkbook workbook = new HSSFWorkbook(upload_file.PostedFile.InputStream);  //==只能讀取 System.IO.Stream
                        for (int x = 0; x < workbook.NumberOfSheets; x++)
                        {
                            HSSFSheet u_sheet   = (HSSFSheet)workbook.GetSheetAt(x); //-- 0表示:第一個 worksheet工作表
                            HSSFRow   headerRow = (HSSFRow)u_sheet.GetRow(I資料起始列);   //-- Excel 表頭列
                            IRow      DateRow   = (IRow)u_sheet.GetRow(I資料起始列);      //-- v.1.2.4版修改
                            str頁簽名稱 = u_sheet.SheetName.ToString();
                            for (int i = I資料起始列; i <= u_sheet.LastRowNum; i++)       //-- 每一列做迴圈
                            {
                                //--不包含 Excel表頭列的 "其他資料列"
                                IRow row = (IRow)u_sheet.GetRow(i);

                                F_資料確認(ref D_table, ref D_errortable, ref DtCula, row, i, ref colorClasses);
                            }
                            //-- 釋放 NPOI的資源
                            u_sheet = null;
                        }
                        //-- 釋放 NPOI的資源
                        workbook = null;
                    }
                    //--錯誤資料顯示
                    if (D_errortable.Rows.Count > 0)
                    {
                        DataView D_View3 = new DataView(D_errortable);
                        ErrorGV.DataSource = D_View3;
                        ErrorGV.DataBind();
                    }
                    if (D_table.Rows.Count > 0)
                    {
                        int i顏色數量 = 0;
                        int.TryParse(匯入筆數DDL.SelectedValue, out i顏色數量);
                        var DistinctColor = ListColor.Distinct().ToList();
                        if (DistinctColor.Count() > 0 && i顏色數量 > 0)
                        {
                            using (DataTable dt = DtCula.Clone())
                            {
                                if (i顏色數量 == 4)
                                {
                                    dt.Columns.RemoveAt(3);
                                    dt.Columns.RemoveAt(2);
                                }

                                if (i顏色數量 >= 2)
                                {
                                    dt.Columns.RemoveAt(1);
                                }
                                dt.Columns[0].ColumnName = "單一顏色";
                                foreach (var item in DistinctColor)
                                {
                                    try
                                    {
                                        DataRow dr = dt.NewRow();
                                        dr[0] = item;
                                        DataView dv1 = new DataView(DtCula), dv2 = new DataView(DtCula), dv3 = new DataView(DtCula), dv4 = new DataView(DtCula);
                                        dv1.RowFilter = $" {DtCula.Columns[0].ColumnName} = '{item}'";
                                        if (i顏色數量 >= 2)
                                        {
                                            dv2.RowFilter = $" {DtCula.Columns[1].ColumnName} = '{item}'";
                                        }
                                        else
                                        {
                                            dv2.Dispose();
                                        }
                                        if (i顏色數量 == 4)
                                        {
                                            dv3.RowFilter = $" {DtCula.Columns[2].ColumnName} = '{item}'";
                                            dv4.RowFilter = $" {DtCula.Columns[3].ColumnName} = '{item}'";
                                        }
                                        else
                                        {
                                            dv3.Dispose();
                                            dv4.Dispose();
                                        }

                                        for (int i = i顏色數量; i < dt.Columns.Count + i顏色數量 - 1; i++)
                                        {
                                            try
                                            {
                                                int x = 0;
                                                if (dv1.Count > 0)
                                                {
                                                    x = F_filter單一顏色數量(dv1, i, x);
                                                }
                                                if (dv2.Count > 0)
                                                {
                                                    x = F_filter單一顏色數量(dv2, i, x);
                                                }
                                                if (dv3.Count > 0)
                                                {
                                                    x = F_filter單一顏色數量(dv3, i, x);
                                                }
                                                if (dv4.Count > 0)
                                                {
                                                    x = F_filter單一顏色數量(dv4, i, x);
                                                }
                                                dr[i - i顏色數量 + 1] = x;
                                            }
                                            catch (Exception ex2)
                                            {
                                                F_ErrorShow($"Error: {ex2.Message}");
                                            }
                                        }
                                        dt.Rows.Add(dr);
                                    }
                                    catch (Exception ex1)
                                    {
                                        F_ErrorShow($"Error: {ex1.Message}");
                                    }
                                }
                                if (dt.Rows.Count > 0)
                                {
                                    GridView3.DataSource = dt;
                                    GridView3.DataBind();


                                    using (XLWorkbook wb = new XLWorkbook())
                                    {
                                        wb.Worksheets.Add(DtCula, "AMZ_PO_Qty");
                                        wb.Worksheets.Add(dt, "AMZ_Color_Qty");
                                        Response.Clear();
                                        Response.Buffer      = true;
                                        Response.Charset     = "";
                                        Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                                        Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", "AMZ_PO"));
                                        using (MemoryStream MyMemoryStream = new MemoryStream())
                                        {
                                            wb.SaveAs(MyMemoryStream);
                                            MyMemoryStream.WriteTo(Response.OutputStream);
                                            Response.Flush();
                                            Response.End();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    F_ErrorShow($"Error: {ex.Message}");
                }
            }
        }
示例#25
0
 public override void addLogMsg(DataTable dtLogResult)
 {
     if ((dtLogResult != null) && (dtLogResult.Rows.Count != 0))
     {
         DataView view = null;
         this.bIsCompleted = false;
         try
         {
             DataRow row;
             view = new DataView(dtLogResult)
             {
                 RowFilter = base.m_dvLogData.RowFilter
             };
             int firstDisplayedScrollingRowIndex = base.dgvLogData.FirstDisplayedScrollingRowIndex;
             dtLogResult.Columns.Add(new DataColumn("ColLog"));
             dtLogResult.Columns.Add(new DataColumn("showImage"));
             int count = view.Count;
             if (base.m_dvLogData.Sort.Length == 0)
             {
                 base.m_dtLogData           = dtLogResult.Clone();
                 base.m_dvLogData           = new DataView(base.m_dtLogData, "", "ReceTime DESC", DataViewRowState.CurrentRows);
                 base.dgvLogData.DataSource = base.m_dvLogData;
             }
             int iRowCnt = base.dgvLogData.Rows.Count + count;
             int num4    = base.m_dvLogData.Count;
             int num5    = 0;
             if (count >= base.iMaxLogCnt)
             {
                 base.m_dtLogData.Rows.Clear();
                 num5 = count - base.iMaxLogCnt;
             }
             else if (iRowCnt > base.iMaxLogCnt)
             {
                 for (int i = 1; i <= (iRowCnt - base.iMaxLogCnt); i++)
                 {
                     base.m_dvLogData.Delete((int)(num4 - i));
                 }
             }
             base.m_dvLogData.Sort = "";
             int num7 = 0;
             while (num5 < count)
             {
                 row = view[num5].Row;
                 row["gpsTime"].ToString();
                 row["carNum"].ToString();
                 row["simNum"].ToString();
                 row["cameraid"].ToString();
                 num7 = base.dgvLogData.SelectedRows.Count;
                 base.m_dtLogData.ImportRow(row);
                 num5++;
             }
             base.SetCurrentRow(base.dgvLogData, iRowCnt, base.iMaxLogCnt, count);
             num7 = base.dgvLogData.SelectedRows.Count;
             row  = null;
             base.m_dvLogData.Sort = "ReceTime DESC";
             if (num7 == 0)
             {
                 base.dgvLogData.ClearSelection();
             }
             if (firstDisplayedScrollingRowIndex >= 0)
             {
                 base.dgvLogData.FirstDisplayedScrollingRowIndex = firstDisplayedScrollingRowIndex;
             }
             base.dgvLogData.Refresh();
             view.Dispose();
             view = null;
         }
         catch (Exception exception)
         {
             if (Variable.bLogin)
             {
                 Record.execFileRecord("图像日志添加操作", exception.Message);
             }
         }
         finally
         {
             if (dtLogResult != null)
             {
                 dtLogResult = null;
             }
             this.bIsCompleted = true;
         }
     }
 }
 public void Dispose()
 {
     _source.Dispose();
 }
示例#27
0
 public void TestDeleteClosed()
 {
     Assert.Throws<IndexOutOfRangeException>(() =>
     {
         DataView TestView = new DataView(_dataTable);
         TestView.Dispose(); // Close the table
         TestView.Delete(0); // cannot access to item at 0.
     });
 }
示例#28
0
 private void PopulateDataGrid(DataView dView)
 {
     grdInvCur.DataSource = dView;
     grdInvCur.DataBind();
     dView.Dispose();
 }
    /*  private void BindTextBox()
     * {
     *    DataSet theDS = new DataSet();
     *    IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
     *    theDS = PatientTransferMgr.GetSatelliteLocation(PatientId, LocationId, SatelliteId, TransferId, 0);
     *    txtLocationName.Text = theDS.Tables[2].Rows[0]["CurrentSatellite"].ToString();
     *    txtTransferDate.Text = theDS.Tables[2].Rows[0]["TransferredDate"].ToString();
     *    //ddSatellite.SelectedValue = theDS.Tables[2].Rows[0]["TransfertoSatellite"].ToString();
     *    ddSatellite.SelectedValue = "0";
     * }*/
    private void BindTransferDetail()
    {
        txtLocationName.Text     = Session["AppLocation"].ToString();
        txtLocationName.ReadOnly = true;

        /*Binding Satellite ID*/
        BindFunctions BindManager = new BindFunctions();
        IQCareUtils   theUtils    = new IQCareUtils();
        DataTable     theDT       = new DataTable();

        DataSet          theDS = new DataSet();
        IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");

        if (btnSave.Text == "Save")
        {
            tredit.Visible       = false;
            theDS                = PatientTransferMgr.GetSatelliteLocation(PatientId, TransferId, 0, Session["SystemId"].ToString());
            txtLocationName.Text = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
            //this.lblpatientname.Text = theDS.Tables[0].Rows[0]["PatientName"].ToString();
            //this.lblpatientenrolment.Text = theDS.Tables[0].Rows[0]["PatientID"].ToString();
            //this.lblexisclinicid.Text = theDS.Tables[0].Rows[0]["PatientClinicID"].ToString();
            DataView theDV = new DataView(theDS.Tables[1]);
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddSatellite, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }
        }
        /*Current Location*/
        //ViewState["FromID"] = theDS.Tables[0].Rows[0]["ID"].ToString();
        //txtLocationName.Text = theDS.Tables[0].Rows[0]["Name"].ToString();

        if (btnSave.Text == "Update")
        {
            tredit.Visible = true;
            theDS          = PatientTransferMgr.GetSatelliteLocation(PatientId, TransferId, 1, Session["SystemId"].ToString());
            // this.lblpatientname.Text = theDS.Tables[0].Rows[0]["PatientName"].ToString();
            // this.lblpatientenrolment.Text = theDS.Tables[0].Rows[0]["PatientID"].ToString();
            // this.lblexisclinicid.Text = theDS.Tables[0].Rows[0]["PatientClinicID"].ToString();
            txtLocationNameEdit.Text    = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
            txtLocationNameEdit.Enabled = false;
            txtFromSatellite.Text       = theDS.Tables[2].Rows[0]["TransferfromSatellite"].ToString();
            txtFromSatellite.Enabled    = false;
            ViewState["FromID"]         = theDS.Tables[2].Rows[0]["TransferredfromID"].ToString();
            //ddSatelliteEdit.Enabled = false;
            TxtTransDateEdit.Text     = string.Format("{0:dd-MMM-yyyy}", Convert.ToDateTime(theDS.Tables[2].Rows[0]["TransferredDate"]));
            ViewState["TransferDate"] = TxtTransDateEdit.Text;
            DataView theDV = new DataView(theDS.Tables[1]);
            //theDV.RowFilter = "DeleteFlag=0";
            if (theDV.Table != null)
            {
                theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                BindManager.BindCombo(ddSatelliteEdit, theDT, "Name", "ID");
                theDV.Dispose();
                theDT.Clear();
            }
            ddSatelliteEdit.SelectedValue = theDS.Tables[2].Rows[0][3].ToString();
        }


        /* else
         * {
         *   theDV = new DataView(theDS.Tables[1]);
         *   theDV.RowFilter = "DeleteFlag=0";
         *   if (theDV.Table != null)
         *   {
         *       theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
         *       BindManager.BindCombo(ddSatellite, theDT, "Name", "ID");
         *       theDV.Dispose();
         *       theDT.Clear();
         *   }
         * }
         */
    }
示例#30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }
            Session["dtWaitingList"]       = null;
            Session["WLTechnicalArea"]     = null;
            Session["WLTechnicalAreaName"] = null;
            Session["WLPatientID"]         = 0;
            btnSubmit.Enabled = false;


            DataTable dtPatientInfo = (DataTable)Session["PatientInformation"];

            if (dtPatientInfo != null)
            {
                lblname.Text = String.Format("{0}, {1}", dtPatientInfo.Rows[0]["LastName"], dtPatientInfo.Rows[0]["FirstName"]);

                lblIQnumber.Text = dtPatientInfo.Rows[0]["IQNumber"].ToString();
                if (Request.QueryString["srvNm"] != null)
                {
                    lblTechnicalArea.Text          = Request.QueryString["srvNm"];
                    Session["WLTechnicalArea"]     = Request.QueryString["mod"];
                    Session["WLTechnicalAreaName"] = Request.QueryString["srvNm"];
                    Session["WLPatientID"]         = Request.QueryString["PID"];
                }
                else
                {
                    lblTechnicalArea.Text          = Session["TechnicalAreaName"].ToString();
                    Session["WLTechnicalArea"]     = Session["TechnicalAreaId"];
                    Session["WLTechnicalAreaName"] = Session["TechnicalAreaName"];
                    Session["WLPatientID"]         = HttpContext.Current.Session["PatientId"];
                }

                using (DataSet theDSXML = new DataSet())
                {
                    theDSXML.ReadXml(MapPath("..\\XMLFiles\\AllMasters.con"));
                    IQCareUtils   theUtils    = new IQCareUtils();
                    BindFunctions BindManager = new BindFunctions();
                    DataView      theDV       = new DataView(theDSXML.Tables["Mst_Decode"]);
                    theDV.RowFilter = "DeleteFlag=0 and CodeID=214";
                    if (theDV.Table != null)
                    {
                        DataTable theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                        DataRow   dr    = theDT.NewRow();
                        dr["Name"] = "Consultation";
                        dr["ID"]   = 1;
                        theDT.Rows.Add(dr);

                        dr         = theDT.NewRow();
                        dr["Name"] = "Laboratory";
                        dr["ID"]   = 3;
                        theDT.Rows.Add(dr);

                        dr         = theDT.NewRow();
                        dr["Name"] = "Pharmacy";
                        dr["ID"]   = 4;
                        theDT.Rows.Add(dr);

                        dr         = theDT.NewRow();
                        dr["Name"] = "Triage";
                        dr["ID"]   = 5;
                        theDT.Rows.Add(dr);

                        BindManager.BindCombo(ddWList, theDT, "Name", "ID");
                        //BindUserDropdown(ddWList, string.Empty);
                        //BindUserDropdown(ddWList, Session["AppUserId"].ToString());
                        theDT.Clear();
                    }
                    theDV.Dispose();
                }

                loadPatientsWaitList(Convert.ToInt32(HttpContext.Current.Session["WLPatientID"]));
                PopulateUsersList();
            }
        }
示例#31
0
    public Decimal calculateSingleLineIncome(string RegNo)
    {
        Decimal intTotalSingleLineTenthLevel = 0;//store single line income upto define level
        Boolean BinaryPaymentValid           = false;

        try
        {
            SqlDataReader MI_MGV_drROOT = RunSqlReturnDR("select RegistrationNo,LeftChildRegNo,RightChildRegNo,Depth_Level,Joining_Points from MI_MGV_registrationDetails where RegistrationNo = '" + RegNo + "' and IsActive =1");
            if (MI_MGV_drROOT.Read())
            {
                Rootlevel = Convert.ToInt32(MI_MGV_drROOT["Depth_Level"]);

                SqlDataReader MI_MGV_drCountchild = RunSqlReturnDR("select count(id) as countId  from MI_MGV_RegistrationDetails where ParentId = '" + RegNo + "' and IsActive =1");
                if (MI_MGV_drCountchild.Read())
                {
                    int countid = Convert.ToInt32(MI_MGV_drCountchild["countId"].ToString());
                    if (countid > 1)
                    {
                        DataView DvLeftRightMemberChilds = RunSQLReturnDV("select top 1 id,Join_Date from MI_MGV_RegistrationDetails where ParentId in ('" + MI_MGV_drROOT["LeftChildRegNo"].ToString() + "','" + MI_MGV_drROOT["RightChildRegNo"].ToString() + "') and IsActive =1 order by id,join_date ");
                        if (DvLeftRightMemberChilds.Count > 0)
                        {
                            FirstLevelPairCreatedOn = Convert.ToDateTime(DvLeftRightMemberChilds[0]["Join_Date"].ToString());

                            SqlDataReader MI_MGV_drCheckReference = RunSqlReturnDR("select count(ReferenceBy) as refcount from MI_MGV_registrationdetails where ReferenceBy = '" + RegNo + "' and IsActive =1"); // atleast two references are mandatory for binary income
                            if (MI_MGV_drCheckReference.Read())
                            {
                                int countreference = Convert.ToInt32(MI_MGV_drCheckReference["refcount"].ToString());
                                if (countreference > 1)
                                {
                                    BinaryPaymentValid = true;
                                }
                            }

                            MI_MGV_drCheckReference.Close();
                            MI_MGV_drCheckReference = null;
                        }

                        DvLeftRightMemberChilds.Dispose();
                        DvLeftRightMemberChilds = null;
                    }
                }
                MI_MGV_drCountchild.Close();
                MI_MGV_drCountchild = null;

                if (BinaryPaymentValid)
                {
                    // Root left Start
                    if (MI_MGV_drROOT["LeftChildRegNo"].ToString() != "0" && MI_MGV_drROOT["LeftChildRegNo"] != null)
                    {
                        SqlDataReader MI_MGV_drMAINLEFT = RunSqlReturnDR("Select RegistrationNo,LeftChildRegNo,RightChildRegNo,Depth_Level,Joining_Points,ID from MI_MGV_registrationDetails where RegistrationNo = '" + MI_MGV_drROOT["LeftChildRegNo"] + "' and IsActive =1");
                        if (MI_MGV_drMAINLEFT.Read())
                        {
                            Check_Pair(MI_MGV_drMAINLEFT["RegistrationNo"].ToString(), MI_MGV_drMAINLEFT["LeftChildRegNo"].ToString(), MI_MGV_drMAINLEFT["RightChildRegNo"].ToString(), Convert.ToInt32(MI_MGV_drMAINLEFT["Depth_Level"]), Convert.ToInt32(MI_MGV_drMAINLEFT["Joining_Points"]), Convert.ToInt32(MI_MGV_drMAINLEFT["ID"]));
                            MI_MGV_drMAINLEFT.Close();
                            MI_MGV_drMAINLEFT = null;
                        }
                    }
                    // Root Left End

                    // Root Right Start
                    if (MI_MGV_drROOT["RightChildRegNo"].ToString() != "0" && MI_MGV_drROOT["RightChildRegNo"] != null)
                    {
                        SqlDataReader MI_MGV_drMAINRIGHT = RunSqlReturnDR("Select RegistrationNo,LeftChildRegNo,RightChildRegNo,Depth_Level,Joining_Points,ID from MI_MGV_registrationDetails where RegistrationNo = '" + MI_MGV_drROOT["RightChildRegNo"] + "' and IsActive =1");
                        if (MI_MGV_drMAINRIGHT.Read())
                        {
                            Check_Pair(MI_MGV_drMAINRIGHT["RegistrationNo"].ToString(), MI_MGV_drMAINRIGHT["LeftChildRegNo"].ToString(), MI_MGV_drMAINRIGHT["RightChildRegNo"].ToString(), Convert.ToInt32(MI_MGV_drMAINRIGHT["Depth_Level"]), Convert.ToInt32(MI_MGV_drMAINRIGHT["Joining_Points"]), Convert.ToInt32(MI_MGV_drMAINRIGHT["ID"]));
                            MI_MGV_drMAINRIGHT.Close();
                            MI_MGV_drMAINRIGHT = null;
                        }
                    }
                    // Root Right End
                    MI_MGV_drROOT.Close();
                    MI_MGV_drROOT = null;

                    // set parent position Start
                    SqlDataReader MI_MGV_DrParentPosition = RunSqlReturnDR("select reg_no,Parent_reg_no,position from MI_MGV_BPayment where LoginMember='" + Session["UserID"].ToString() + "'");
                    if (MI_MGV_DrParentPosition.HasRows)
                    {
                        while (MI_MGV_DrParentPosition.Read())
                        {
                            setParentPosition(MI_MGV_DrParentPosition["reg_no"].ToString(), MI_MGV_DrParentPosition["Parent_reg_no"].ToString(), Convert.ToInt32(MI_MGV_DrParentPosition["position"]));
                        }
                    }

                    MI_MGV_DrParentPosition.Close();
                    MI_MGV_DrParentPosition = null;
                    // set parent position End

                    // start calculation for Single Line payment start
                    int intTotalSingleLinePayment = 0;
                    int TenthLevel         = Rootlevel + SingleLineRateMaxLevel;
                    int LeftJoiningPoints  = 0;
                    int RightJoiningPoints = 0;
                    int TotalBinaryPoints  = 0;
                    int CarryPoints        = 0;
                    int leftcarrypoints    = 0;
                    int rightcarrypoints   = 0;


                    SqlDataReader MI_MGV_drCarryPoints = RunSqlReturnDR("select Left_CarryPoints,Right_CarryPoints from MI_MGV_registrationDetails where RegistrationNo = '" + RegNo + "' and IsActive =1");
                    if (MI_MGV_drCarryPoints.Read())
                    {
                        leftcarrypoints  = Convert.ToInt32(MI_MGV_drCarryPoints["Left_CarryPoints"]);
                        rightcarrypoints = Convert.ToInt32(MI_MGV_drCarryPoints["Right_CarryPoints"]);
                    }
                    MI_MGV_drCarryPoints.Close();
                    MI_MGV_drCarryPoints = null;

                    SqlDataReader MI_MGV_drCheckFirstPayment = RunSqlReturnDR("select Reg_No from MI_MGV_Weekly_Payment where Reg_No = '" + RegNo + "'"); // check for first week
                    if (MI_MGV_drCheckFirstPayment.Read())
                    {
                        SqlDataReader MI_MGV_drLeftPoints = RunSqlReturnDR("select case when sum(Joining_Points) IS NULL then 0 else sum(Joining_Points) end as leftJoining_Points from MI_MGV_BPayment where LoginMember = '" + Session["UserID"].ToString() + "' and Parent_Position = 0 and level <= " + TenthLevel + " and Join_Date between '" + StartDateOfWeek.ToShortDateString() + "' and '" + EndDateOfWeek.ToShortDateString() + "'");
                        if (MI_MGV_drLeftPoints.Read())
                        {
                            LeftJoiningPoints = Convert.ToInt32(MI_MGV_drLeftPoints["leftJoining_Points"]) + leftcarrypoints;
                        }
                        MI_MGV_drLeftPoints.Close();
                        MI_MGV_drLeftPoints = null;

                        SqlDataReader MI_MGV_drRightPoints = RunSqlReturnDR("select case when sum(Joining_Points) IS NULL then 0 else sum(Joining_Points) end as leftJoining_Points from MI_MGV_BPayment where LoginMember = '" + Session["UserID"].ToString() + "' and Parent_Position = 1 and level <= " + TenthLevel + " and Join_Date between '" + StartDateOfWeek.ToShortDateString() + "' and '" + EndDateOfWeek.ToShortDateString() + "'");
                        if (MI_MGV_drRightPoints.Read())
                        {
                            RightJoiningPoints = Convert.ToInt32(MI_MGV_drRightPoints["leftJoining_Points"]) + rightcarrypoints;
                        }
                        MI_MGV_drRightPoints.Close();
                        MI_MGV_drRightPoints = null;
                    }
                    else
                    {
                        SqlDataReader MI_MGV_drLeftPoints = RunSqlReturnDR("select case when sum(Joining_Points) IS NULL then 0 else sum(Joining_Points) end as leftJoining_Points from MI_MGV_BPayment where LoginMember = '" + Session["UserID"].ToString() + "' and Parent_Position = 0 and level <= " + TenthLevel + "");
                        if (MI_MGV_drLeftPoints.Read())
                        {
                            LeftJoiningPoints = Convert.ToInt32(MI_MGV_drLeftPoints["leftJoining_Points"]) + leftcarrypoints;
                        }
                        MI_MGV_drLeftPoints.Close();
                        MI_MGV_drLeftPoints = null;

                        SqlDataReader MI_MGV_drRightPoints = RunSqlReturnDR("select case when sum(Joining_Points) IS NULL then 0 else sum(Joining_Points) end as leftJoining_Points from MI_MGV_BPayment where LoginMember = '" + Session["UserID"].ToString() + "' and Parent_Position = 1 and level <= " + TenthLevel + "");
                        if (MI_MGV_drRightPoints.Read())
                        {
                            RightJoiningPoints = Convert.ToInt32(MI_MGV_drRightPoints["leftJoining_Points"]) + rightcarrypoints;
                        }

                        MI_MGV_drRightPoints.Close();
                        MI_MGV_drRightPoints = null;
                    }

                    if (RightJoiningPoints >= LeftJoiningPoints)
                    {
                        CarryPoints       = RightJoiningPoints - LeftJoiningPoints;
                        TotalBinaryPoints = RightJoiningPoints - CarryPoints;
                    }
                    else
                    {
                        CarryPoints       = LeftJoiningPoints - RightJoiningPoints;
                        TotalBinaryPoints = LeftJoiningPoints - CarryPoints;
                    }

                    MI_MGV_drCheckFirstPayment.Close();
                    MI_MGV_drCheckFirstPayment = null;

                    intTotalSingleLinePayment    = 2 * TotalBinaryPoints;
                    intTotalSingleLineTenthLevel = intTotalSingleLinePayment * SingleLineRate / 100;
                }

                RunSql("Delete from MI_MGV_BPayment where LoginMember='" + Session["UserID"].ToString() + "'");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex);
        }

        return(intTotalSingleLineTenthLevel);
    }