Пример #1
0
 public CSVWritter(DataGridViewRowCollection _rows)
 {
     rows = _rows;
 }
Пример #2
0
        void Browser.run()
        {
            while (true)
            {
                DataGridViewRowCollection  rows  = form.getTableRows();
                DataGridViewRow            row   = rows[CommonUtils.GetRandomValue(0, rows.Count)];
                DataGridViewCellCollection cells = row.Cells;

                //SetAgentType(getCellValue(cells, Main.HEADER_AGENT));

                if (!form.isRemainTask())
                {
                    break;
                }

                if (int.Parse(getCellValue(cells, Main.HEADER_TO_COUNT)) == int.Parse(getCellValue(cells, Main.HEADER_CURR_COUNT)))
                {
                    continue;
                }

                List <Configuration> Configs = sqlite.SelectAllConfigurationByOwner(getCellValue(cells, Main.HEADER_SLOT));
                if (Configs == null || Configs.Count == 0)
                {
                    Configs = sqlite.SelectAllConfigurationByOwner(Configuration.Default);
                }

                Dictionary <string, string> dictionary = Configuration.ConvertObjectToMap(Configs);

                //  string searchText = getCellValue(cells, Main.HEADER_SEARCH);
                //   string nxSearchText = getCellValue(cells, Main.HEADER_NXSEARCH);

                try
                {
                    logManager.AppendLog("//========슬롯[{0}]의 작업을 시작합니다.========//", getCellValue(cells, Main.HEADER_SLOT));

                    form.BeginInvoke(new Action(() => { form.ChangeRowColor(row, Color.LawnGreen); }));

                    // 브라우저 시작
                    //  StartBrowser( dictionary, getCellValue(cells, Main.HEADER_BROWSER));

                    // 검색어 입력
                    //SetSearchText("#query", searchText, false);

                    // 검색전 체류
                    Stay("1차 검색 전", dictionary[Configuration.COMMON_PRE_SEARCH_STAY]);

                    // 1차 검색
                    if (agentType == Slot.AGENT_TYPE_PC)
                    {
                        ClickSearchBtn("search_btn");
                    }
                    else
                    {
                        ClickSearchBtn("query");
                    }

                    // 랭크 처리
                    //   form.SetSearchRank(row, FindSearchRank(nxSearchText));

                    // 검색 후 체류
                    Stay("1차 검색 후", dictionary[Configuration.COMMON_SEARCH_STAY]);

                    // 스크롤 처리
                    ScrollBy(dictionary);

                    // 카테고리 이동
                    //   int index = MoveTab( getCellValue(cells, Main.HEADER_CATEGORY));

                    // 카테고리 이동 후 체류
                    Stay("카테고리 이동 후", dictionary[Configuration.COMMON_SEARCH_STAY]);

                    // 2차 검색어 입력
                    //   SetSearchText("#nx_query", nxSearchText, true);

                    // 검색전 체류
                    Stay("2차 검색 전", dictionary[Configuration.COMMON_PRE_SEARCH_STAY]);

                    // 2차 검색
                    if (agentType == Slot.AGENT_TYPE_PC)
                    {
                        ClickSearchBtn("bt_search");
                    }
                    else
                    {
                        ClickSearchBtn("nx_query");
                    }

                    // 검색 후 체류
                    Stay("2차 검색 후", dictionary[Configuration.COMMON_SEARCH_STAY]);

                    int MaxPageCount = CommonUtils.GetRandomValue(dictionary[Configuration.COMMON_MAX_PAGE]);
                    for (int i = 0; i < MaxPageCount; i++)
                    {
                        // 스크롤 처리
                        ScrollBy(dictionary);

                        // 게시물 조회
                        //  bool isViewSuccess = PostViewBy(index, null, 1500, true);

                        // 게시물 조회 성공
                        // if (isViewSuccess)
                        // {
                        // 스크롤 처리
                        //    ScrollBy(dictionary);

                        // 최초방문페이지 체류
                        Stay("최초 페이지 방문 후", dictionary[Configuration.COMMON_INIT_PAGE_STAY]);
                        //   }

                        // 이전 히스토리 이동
                        HistoryBack();

                        // 이전 히스토리 이동 후 체류 시간
                        Stay("히스토리 이전으로 이동 후", dictionary[Configuration.COMMON_PRE_HISTORY_MOVE_STAY]);
                    }

                    DeleteCookie();

                    // 쿠키삭제 후 체류
                    Stay("쿠키 삭제 후", dictionary[Configuration.COOKIE_DELETE_POST_STAY]);

                    // 카운트 증가
                    ComplateProcess(row);

                    //브라우저 종료
                    CloseBrowser();

                    // 아이피 변경
                    ChangeIP(dictionary);

                    logManager.AppendLog("//========슬롯[{0}]의 작업을 종료합니다.========//", getCellValue(cells, Main.HEADER_SLOT));
                }
                catch (Exception e)
                {
                    logManager.AppendLog("Nested Exception : {0}", e.Message);

                    // 작업 종료
                    if (e is ThreadAbortException)
                    {
                        form.EnableWorkBtn(false, "정지 중");
                        ClosingProcess(row);
                        logManager.AppendLog("정상적으로 작업이 중지 되었습니다.");
                        form.EnableWorkBtn(true, "작업 실행");
                    }
                    else
                    {
                        ClosingProcess(row);
                        logManager.AppendLog("[EXCEPTION] 브라우저가 강제적으로 종료되었거나 알 수 없는 오류가 발생 하였습니다.");
                    }

                    break;
                }

                form.EnableWorkBtn(true, "작업 실행");
            }
        }
        public static DataGridViewRow AddNew(this DataGridViewRowCollection collection)
        {
            int iDx = collection.Add();

            return(collection[iDx]);
        }
Пример #4
0
        private void buttSave_Click(object sender, EventArgs e)
        {
            if (txtRef.Text == "")
            {
                string    order = "select Deliveryidfrom CustomerOrderDelivery";
                DataTable dt1   = dbMainClass.getDetailByQuery(order);
                string    id2   = "";
                string    id5   = "";
                foreach (DataRow dr in dt1.Rows)
                {
                    id5 = dr[0].ToString();
                }
                string    order1 = "select Orderid from VendorOrderDetails";
                DataTable dt4    = dbMainClass.getDetailByQuery(order1);
                foreach (DataRow dr in dt4.Rows)
                {
                    id2 = dr[0].ToString();
                }
                string OrderID = "";
                if (id2 == "")
                {
                    id2     = "1";
                    OrderID = id2;
                    string insertqurry  = "insert into VendorOrderDetails values('" + txtVendorId.Text + "','" + dtpInvoiceDate.Text + "','" + txtTotalAmount.Text + "')";
                    int    insertedRows = dbMainClass.saveDetails(insertqurry);
                    //if (insertedRows > 0)
                    //{
                    DataGridViewRowCollection RowCollection = dataGridView1.Rows;
                    List <string>             sf            = new List <string>();
                    for (int a = 0; a < RowCollection.Count; a++)
                    {
                        DataGridViewRow            currentRow     = RowCollection[a];
                        DataGridViewCellCollection cellCollection = currentRow.Cells;
                        string txtItemCod = cellCollection[0].Value.ToString();
                        string txtRate    = cellCollection[2].Value.ToString();
                        string txtQuanit  = cellCollection[3].Value.ToString();
                        string txtAmoun   = cellCollection[5].Value.ToString();

                        string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCod + "','" + txtRate + "','" + txtQuanit + "','" + txtAmoun + "')";
                        //MessageBox.Show(Query);
                        sf.Add(Query);
                    }
                    int insertedRows1 = dbMainClass.saveDetails(sf);
                    if (insertedRows1 > 0)
                    {
                        if (id5 == "")
                        {
                            string    deleteQurry = "delete VendorOrderDesc where Orderid='" + id2 + "'";
                            DataTable dt          = dbMainClass.getDetailByQuery(deleteQurry);
                            //dataGridView1.DataSource = "";


                            DataGridViewRowCollection RowCollection2 = dataGridView1.Rows;
                            List <string>             sf1            = new List <string>();
                            for (int a = 0; a < RowCollection2.Count; a++)
                            {
                                DataGridViewRow            currentRow     = RowCollection2[a];
                                DataGridViewCellCollection cellCollection = currentRow.Cells;
                                string txtItemCode = cellCollection[0].Value.ToString();
                                string txtRate     = cellCollection[2].Value.ToString();
                                string txtQuanity  = cellCollection[4].Value.ToString();
                                string txtAmoun    = cellCollection[5].Value.ToString();
                                string OrderID1    = id2;

                                string Query = "insert into VendorOrderDesc Values('" + OrderID1 + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')";
                                //MessageBox.Show(Query);

                                sf1.Add(Query);
                            }
                            int insertedRows4 = dbMainClass.saveDetails(sf1);
                            if (insertedRows4 > 0)
                            {
                                string insertQurry   = "insert into CustomerOrderDelivery Values('" + txtRef.Text + "','true','" + dtpInvoiceDate.Text + "')";
                                int    insertedRows2 = dbMainClass.saveDetails(insertQurry);
                                if (insertedRows2 > 0)
                                {
                                    MessageBox.Show("Details Saved Successfully");
                                }
                                else
                                {
                                    MessageBox.Show("Details Not Saved Successfully");
                                }
                            }
                        }
                    }
                }
                else
                {
                    int id3 = Convert.ToInt32(id2);
                    int id4 = id3 + 1;
                    OrderID = id4.ToString();
                    string insertqurry1  = "insert into VendorOrderDetails values('" + txtVendorId.Text + "','" + dtpInvoiceDate.Text + "','" + txtTotalAmount.Text + "')";
                    int    insertedRows1 = dbMainClass.saveDetails(insertqurry1);
                    //if (insertedRows1 > 0)
                    //{
                    DataGridViewRowCollection RowCollection = dataGridView1.Rows;
                    List <string>             sf            = new List <string>();
                    for (int a = 0; a < RowCollection.Count; a++)
                    {
                        DataGridViewRow            currentRow     = RowCollection[a];
                        DataGridViewCellCollection cellCollection = currentRow.Cells;
                        string txtItemCod = cellCollection[0].Value.ToString();
                        string txtRate    = cellCollection[2].Value.ToString();
                        string txtQuanit  = cellCollection[3].Value.ToString();
                        string txtAmoun   = cellCollection[4].Value.ToString();

                        string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCod + "','" + txtRate + "','" + txtQuanit + "','" + txtAmoun + "')";
                        //MessageBox.Show(Query);
                        sf.Add(Query);
                    }
                    int insertedRows2 = dbMainClass.saveDetails(sf);
                    if (insertedRows2 > 0)
                    {
                        string    deleteQurry1 = "delete VendorOrderDesc where Orderid='" + OrderID + "'";
                        DataTable dt5          = dbMainClass.getDetailByQuery(deleteQurry1);
                        //dataGridView1.DataSource = "";

                        DataGridViewRowCollection RowCollection1 = dataGridView1.Rows;
                        List <string>             sf2            = new List <string>();
                        for (int a = 0; a < RowCollection1.Count; a++)
                        {
                            DataGridViewRow            currentRow     = RowCollection1[a];
                            DataGridViewCellCollection cellCollection = currentRow.Cells;
                            string txtItemCode = cellCollection[0].Value.ToString();
                            string txtRate     = cellCollection[2].Value.ToString();
                            string txtQuanity  = cellCollection[3].Value.ToString();
                            string txtAmoun    = cellCollection[4].Value.ToString();
                            string OrderID2    = OrderID;

                            string Query = "insert into VendorOrderDesc Values('" + OrderID2 + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')";
                            //MessageBox.Show(Query);

                            sf2.Add(Query);
                        }
                        int insertedRows3 = dbMainClass.saveDetails(sf2);
                        if (insertedRows3 > 0)
                        {
                            string insertQurry   = "insert into CustomerOrderDelivery Values('" + OrderID + "','true','" + dtpInvoiceDate.Text + "')";
                            int    insertedRows5 = dbMainClass.saveDetails(insertQurry);
                            if (insertedRows5 > 0)
                            {
                                string    select1 = "select * from CustomerOrderDelivery where Orderid='" + OrderID + "'";
                                DataTable dt2     = dbMainClass.getDetailByQuery(select1);
                                if (dt2 != null && dt2.Rows != null && dt2.Rows.Count > 0)
                                {
                                    DataRow dr1 = dt2.Rows[0];
                                    string  r   = dr1[1].ToString();
                                    string  s   = dr1[0].ToString();

                                    string    select = "select * from CustomerOrderDelivery where Deliveryid='" + s + "'";
                                    DataTable dt     = dbMainClass.getDetailByQuery(select);
                                    if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                                    {
                                        DataRow dr = dt.Rows[0];
                                        string  c  = dr[0].ToString();

                                        string Qurry1       = "insert into CustomerOrderInvoice Values('" + c + "','" + r + "','" + dtpInvoiceDate.Text + "')";
                                        int    insertedRows = dbMainClass.saveDetails(Qurry1);
                                        if (insertedRows > 0)
                                        {
                                            MessageBox.Show("Details Saved Successfully");
                                        }
                                        else
                                        {
                                            MessageBox.Show("Details Not Saved Successfully");
                                        }
                                    }
                                }
                                // }
                            }
                        }
                    }
                }


                int id  = Convert.ToInt32(txtSrNo.Text);
                int id1 = id + 1;
                txtSrNo.Text = id1.ToString();
                // F9.MdiParent = this;
                Form9 F9 = new Form9(id.ToString());
                F9.Show();
                makeBlank();
            }

            if (txtRef.Text != "")
            {
                string    select1 = "select * from CustomerOrderDelivery where Deliveryid='" + txtRef.Text + "'";
                DataTable dt2     = dbMainClass.getDetailByQuery(select1);
                if (dt2 != null && dt2.Rows != null && dt2.Rows.Count > 0)
                {
                    DataRow   dr1         = dt2.Rows[0];
                    string    r           = dr1[1].ToString();
                    string    deleteQurry = "delete VendorOrderDesc where Orderid='" + r + "'";
                    DataTable dt3         = dbMainClass.getDetailByQuery(deleteQurry);
                }
                counter = 0;
                if (counter == 0)
                {
                    //string insertqurry = "insert into VendorOrderDetails values('" +txtVendorId.Text + "','" + txtdate.Text + "','" + txtTotalAmount.Text + "')";
                    //int insertedRows = dbMainClass.saveDetails(insertqurry);
                    //if (insertedRows > 0)
                    //{

                    //    MessageBox.Show("Details Saved Successfully");

                    //}
                    //else
                    //{
                    //    MessageBox.Show("Details Not Saved Successfully");
                    //}
                    string    select = "select * from CustomerOrderDelivery where Deliveryid='" + txtRef.Text + "'";
                    DataTable dt     = dbMainClass.getDetailByQuery(select);
                    if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                    {
                        DataRow dr = dt.Rows[0];
                        string  c  = dr[1].ToString();
                        DataGridViewRowCollection RowCollection4 = dataGridView1.Rows;
                        List <string>             sf4            = new List <string>();
                        for (int a = 0; a < RowCollection4.Count; a++)
                        {
                            DataGridViewRow            currentRow     = RowCollection4[a];
                            DataGridViewCellCollection cellCollection = currentRow.Cells;
                            string txtItemCode = cellCollection[0].Value.ToString();
                            string txtRate     = cellCollection[2].Value.ToString();
                            string txtQuanity  = cellCollection[3].Value.ToString();
                            string txtAmoun    = cellCollection[4].Value.ToString();
                            string OrderID3    = c;
                            string Query       = "insert into VendorOrderDesc Values('" + OrderID3 + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')";
                            //MessageBox.Show(Query);
                            sf4.Add(Query);
                        }
                        int insertedRows5 = dbMainClass.saveDetails(sf4);
                        if (insertedRows5 > 0)
                        {
                            string Qurry1       = "insert into CustomerOrderInvoice Values('" + txtRef.Text + "','" + c + "','" + dtpInvoiceDate.Text + "')";
                            int    insertedRows = dbMainClass.saveDetails(Qurry1);
                            if (insertedRows > 0)
                            {
                                MessageBox.Show("Details Saved Successfully");
                            }
                            else
                            {
                                MessageBox.Show("Details Not Saved Successfully");
                            }
                        }
                    }
                }
                //}

                //F9.MdiParent = this;
                makeBlank();
                int id  = Convert.ToInt32(txtSrNo.Text);
                int id1 = id + 1;
                txtSrNo.Text = id1.ToString();
                Form9 F9 = new Form9(id.ToString());
                F9.Show();
            }
        }
Пример #5
0
        // Local mouse action event handler
        public void MouseAction(object sender, MouseActionEventArgs e)
        {
            Form1 form = (Form1)sender;
            DataGridViewRowCollection rows = form.dataGridView1.Rows;

            rows[form.index].Cells[0].Value = Enum.GetName(typeof(MouseMessages), e.mouseMessage);
            rows[form.index].Cells[1].Value = e.point.x;
            rows[form.index].Cells[2].Value = e.point.y;

            switch (e.mouseMessage)
            {
            case MouseMessages.WM_MOUSEMOVE:
                if (form.isNewRow)
                {
                    //rows[form.index].Cells[0].Value = "Move";
                    form.isNewRow = false;
                }

                // Exits the global low level mouse hook, calls GC.Collect() actively, and then reenters a new hook
                form.SetHook(Form1.WH_MOUSE_LL);
                return;

                /*case MouseMessages.WM_LBUTTONDOWN:
                 *  rows[form.index].Cells[0].Value = "Left Button Down";
                 *  break;
                 *
                 * case MouseMessages.WM_RBUTTONDOWN:
                 *  rows[form.index].Cells[0].Value = "Right Button Down";
                 *  break;
                 *
                 * case MouseMessages.WM_LBUTTONUP:
                 *  rows[form.index].Cells[0].Value = "Left Button Up";
                 *  break;
                 *
                 * case MouseMessages.WM_RBUTTONUP:
                 *  rows[form.index].Cells[0].Value = "Right Button Up";
                 *  break;*/
            }

            Window win = new Tool().getWindow(e.hWnd, e.point);

            if (win != null)
            {
                //high light window's frame
                switch (e.mouseMessage)
                {
                case MouseMessages.WM_LBUTTONDOWN:
                case MouseMessages.WM_RBUTTONDOWN:
                    win.DrawFrame();
                    lastWin = win;
                    break;

                case MouseMessages.WM_LBUTTONUP:
                case MouseMessages.WM_RBUTTONUP:
                    lastWin.DrawFrame();

                    if (lastWin.hWnd != win.hWnd)
                    {
                        //win.DrawFrame();
                        Thread thd = new Thread(Window.DrawFrame);
                        thd.Name = "delay";
                        thd.Start(win);
                    }
                    lastWin = null;

                    break;
                }

                // Exits the global low level mouse hook, calls GC.Collect() actively, and then reenters a new hook
                form.SetHook(Form1.WH_MOUSE_LL);

                if (!form.windows.ContainsKey(win.hWnd))
                {
                    form.windows.Add(win.hWnd, win);
                }
                rows[form.index].Cells[3].Value = win.hWnd.ToString();

                form.dataGridView1.ClearSelection();
                rows[form.index++].Cells[3].Selected = true;
                form.isNewRow = true;
                if (form.index >= form.dataGridView1.Rows.Count)
                {
                    form.StopTracking_Click(null, null);
                }

                if (!form.splitContainer1.Panel2Collapsed)
                {
                    form.showWindowProperties(win.hWnd);
                }
            }
        }
        /// <summary>
        /// Метод инициализации выражений
        /// </summary>
        /// <param name="dgvrCollection">Строки с таблицы со списком выражений на форме MainForm</param>
        /// <param name="newRowIndex">Индекс новой строки в таблице</param>
        /// <param name="loggingService">Сервис логирования</param>
        public static List <Expression> initExpressions(DataGridViewRowCollection dgvrCollection, int newRowIndex, LoggingService loggingService)
        {
            loggingService.logString("\n\n----------Ввод выражений:----------------\n");

            List <Expression> expressions = new List <Expression>();

            bool processingTerminated = false;

            int index = 1;

            foreach (DataGridViewRow dgvr in dgvrCollection)
            {
                if (dgvr.Index == newRowIndex)
                {
                    break;
                }

                if (dgvr.Cells[0].Value == null || dgvr.Cells[0].Value.ToString().Length == 0)
                {
                    loggingService.logError("Ошибка в строке " + dgvr.Index.ToString() + ": не задано выражение ЕСЛИ\n");
                    processingTerminated = true;
                    break;
                }

                if (dgvr.Cells[1].Value == null || dgvr.Cells[1].Value.ToString().Length == 0)
                {
                    loggingService.logError("Ошибка в строке " + dgvr.Index.ToString() + ": не задано выражение ТО\n");
                    processingTerminated = true;
                    break;
                }

                int openBracketCount = 0, closeBracketCount = 0;
                foreach (char c in dgvr.Cells[0].Value.ToString())
                {
                    if (c == '(')
                    {
                        openBracketCount++;
                    }
                    else if (c == ')')
                    {
                        closeBracketCount++;
                    }
                }

                if (openBracketCount != closeBracketCount)
                {
                    loggingService.logError("Ошибка в строке " + dgvr.Index.ToString() +
                                            ": количество открывающих скобок (" + openBracketCount +
                                            ") не совпадает с количеством закрывающих (" + closeBracketCount + ")\n");
                    processingTerminated = true;
                    break;
                }

                Expression expression = new Expression(index, dgvr.Cells[0].Value.ToString(), dgvr.Cells[1].Value.ToString(),
                                                       dgvr.Cells[2].Value != null ? dgvr.Cells[2].Value.ToString() : string.Empty);
                expressions.Add(expression);

                index++;
            }

            if (!processingTerminated)
            {
                loggingService.logExpressions(expressions);
            }

            return(expressions);
        }
Пример #7
0
        public ShowArticleList(MainForm pParent, DataGridViewRowCollection inrowcol)
        {
            InitializeComponent();
            rowcol  = inrowcol;
            mParent = pParent;

            overlay   = mParent.mGFXEngines[(int)eEngines.OVERLAY];
            projector = mParent.mGFXEngines[(int)eEngines.PROJECTOR];

            lButtons.Add(button1);
            lButtons.Add(button2);
            lButtons.Add(button3);
            lButtons.Add(button4);
            lButtons.Add(button5);
            lButtons.Add(button6);
            lButtons.Add(button7);
            lButtons.Add(button8);
            lButtons.Add(button9);
            lButtons.Add(button10);
            lButtons.Add(button11);
            lButtons.Add(button12);
            lButtons.Add(button13);
            lButtons.Add(button14);
            lButtons.Add(button15);

            larticlesused.Add(marticle1used);
            larticlesused.Add(marticle2used);
            larticlesused.Add(marticle3used);
            larticlesused.Add(marticle4used);
            larticlesused.Add(marticle5used);
            larticlesused.Add(marticle6used);
            larticlesused.Add(marticle7used);
            larticlesused.Add(marticle8used);
            larticlesused.Add(marticle9used);
            larticlesused.Add(marticle10used);
            larticlesused.Add(marticle11used);
            larticlesused.Add(marticle12used);
            larticlesused.Add(marticle13used);
            larticlesused.Add(marticle14used);
            larticlesused.Add(marticle15used);

            int cnt = 0;

            foreach (DataGridViewRow row in inrowcol)
            {
                long templong;
                long.TryParse(row.Cells[1].Value.ToString(), out templong);

                larticles.Add(new articles(row.Cells[0].Value.ToString(), templong));
                //lArticles.Add(row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString());
                //lButtons[cnt].Text = row.Cells[0].Value.ToString() +" - " + row.Cells[1].Value.ToString();
                cnt++;
            }

            for (int i = cnt; i < 15; i++)
            {
                lButtons[i].Visible = false;
            }

            // new sort the dictionary alphabetic..
            //lList = lArticles.Keys.ToList();
            //larticles.Sort();
            //var lsortedarticles = larticles.OrderBy(price => price).ToList();
            larticles.Sort((x, y) => string.Compare(x.name, y.name));

            cnt = 0;
            foreach (articles art in larticles)
            {
                lButtons[cnt].Text = art.name + " - " + art.price;
                cnt++;
            }
        }
Пример #8
0
        private void saleLoadData(int pageNum)
        {
            int total = 0;

            dgvSale.Rows.Clear();
            DataGridViewRowCollection rows = dgvSale.Rows;
            RosterDial_RInfo          view = new RosterDial_RInfo(APConfig.Conn);

            view.Conditions = " 1=1 ";
            if (!string.IsNullOrEmpty(txtSaleItem.Text))
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.item.ToString(), txtSaleItem.Text);
            }
            if (!string.IsNullOrEmpty(txtSaleMain.Text))
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.main.ToString(), txtSaleMain.Text);
            }
            if (!string.IsNullOrEmpty(txtSaleName.Text))
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.name.ToString(), txtSaleName.Text);
            }
            if (!string.IsNullOrEmpty(txtSaleComment.Text))
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.comment.ToString(), txtSaleComment.Text);
            }
            //if (!string.IsNullOrEmpty(dpkSaleInsertSDTTM.Value.ToString()) && ckbSaleInsertDTTM.Checked)
            //    view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.createSDTTM.ToString(), dpkSaleInsertSDTTM.Value.ToString("yyyy/MM/dd"));
            //if (!string.IsNullOrEmpty(dpkSaleInsertSDTTM.Value.ToString()) && ckbSaleInsertDTTM.Checked)
            //    view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.createEDTTM.ToString(), dpkSaleInsertSDTTM.Value.ToString("yyyy/MM/dd"));
            if (!string.IsNullOrEmpty(dpkSaleModifySDTTM.Value.ToString()) && ckbSaleModifyDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.modifySDTTM.ToString(), dpkSaleModifySDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkSaleModifyEDTTM.Value.ToString()) && ckbSaleModifyDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.modifyEDTTM.ToString(), dpkSaleModifyEDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkSaleDealSDTTM.Value.ToString()) && ckbSaleDealDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.dealSDTTM.ToString(), dpkSaleDealSDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkSaleDealEDTTM.Value.ToString()) && ckbSaleDealDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.dealEDTTM.ToString(), dpkSaleDealEDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (ddlSaleDealer.SelectedIndex != 0)
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.dealer.ToString(), ddlSaleDealer.SelectedItem.ToString());
            }
            if (ddlSaleStatus.SelectedIndex != 0)
            {
                view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.status.ToString(), ddlSaleStatus.SelectedItem.ToString());
            }
            if (ddlSaleType.SelectedIndex != 0)
            {
                if (ddlSaleType.SelectedItem.ToString() == "銷貨淨值") //Harsh Code
                {
                    view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.typelist.ToString(), " '銷貨收入','銷貨折扣'");
                }
                else
                {
                    view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.type.ToString(), ddlSaleType.SelectedItem.ToString());
                }
            }
            //組排序指令
            if (dgvSale.SortedColumn is null)
            {
                view.OrderBy = view.getOptionOrderBy(RosterDial_RInfo.ncSort.Default.ToString());
            }
            else
            {
                string sortname = dgvSale.SortedColumn.Name;
                string sortmode = APConfig.GetValueFromDescription <SortMode>(dgvSale.SortOrder.ToString()).ToString();
                view.OrderBy = string.Format("{0} {1}", view.getOptionOrderBy(sortname), sortmode);
            }
            //查詢頁數初始化且自動跳轉至第一頁
            if (pageNum == 0)
            {
                APConfig.loadPage(ddlSalePage, view.calculatePage(APConfig.PageCount));
                return;
            }
            //計算總合
            if (view.load())
            {
                while (!view.IsEof)
                {
                    total += int.Parse(view.RSD_AMOUNT);
                    view.next();
                }
            }
            //塞入資料
            DataSet ds = APConfig.GoPage(view.SQLStatement, pageNum);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                rows.Add(new Object[] { dr.ItemArray[0], dr.ItemArray[14], dr.ItemArray[13], dr.ItemArray[1], dr.ItemArray[2], dr.ItemArray[3], dr.ItemArray[6], dr.ItemArray[4], dr.ItemArray[5], dr.ItemArray[7], dr.ItemArray[10] });
            }
            lblSaleTotal.Text       = view.calculateCount().ToString();
            lblSaleTotalAmount.Text = string.Format("{0:n0} 元", total);
        }
Пример #9
0
        private void memberLoadData(int pageNum)
        {
            dgvMember.Rows.Clear();
            DataGridViewRowCollection rows = dgvMember.Rows;
            RosterInfo vRoster             = new RosterInfo(APConfig.Conn);

            vRoster.Conditions = " 1=1 ";
            if (!string.IsNullOrEmpty(txtMemberName.Text))
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.name.ToString(), txtMemberName.Text);
            }
            if (!string.IsNullOrEmpty(txtMemberTel.Text))
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.phoneLike.ToString(), txtMemberTel.Text);
            }
            if (!string.IsNullOrEmpty(txtMemberAddr.Text))
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.address.ToString(), txtMemberAddr.Text);
            }
            if (!string.IsNullOrEmpty(dpkMemberInsertSDTTM.Value.ToString()) && ckbMemberInsertDTTM.Checked)
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.createSDTTM.ToString(), dpkMemberInsertSDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkMemberInsertEDTTM.Value.ToString()) && ckbMemberInsertDTTM.Checked)
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.createEDTTM.ToString(), dpkMemberInsertEDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkMemberModifySDTTM.Value.ToString()) && ckbMemberModifyDTTM.Checked)
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.modifySDTTM.ToString(), dpkMemberModifySDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkMemberModifyEDTTM.Value.ToString()) && ckbMemberModifyDTTM.Checked)
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.modifyEDTTM.ToString(), dpkMemberModifyEDTTM.Value.ToString("yyyy/MM/dd"));
            }
            //組排序指令
            if (dgvMember.SortedColumn is null)
            {
                vRoster.OrderBy = vRoster.getOptionOrderBy(RosterInfo.ncSort.Default.ToString());
            }
            else
            {
                string sortname = dgvMember.SortedColumn.Name;
                string sortmode = APConfig.GetValueFromDescription <SortMode>(dgvMember.SortOrder.ToString()).ToString();
                vRoster.OrderBy = string.Format("{0} {1}", vRoster.getOptionOrderBy(sortname), sortmode);
            }
            //查詢頁數初始化且自動跳轉至第一頁
            if (pageNum == 0)
            {
                APConfig.loadPage(ddlMemberPage, vRoster.calculatePage(APConfig.PageCount));
                return;
            }
            //塞入資料
            lblMemberTotal.Text = vRoster.calculateCount().ToString();
            DataSet ds = APConfig.GoPage(vRoster.SQLStatement, pageNum);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                rows.Add(new Object[] { dr.ItemArray[0], dr.ItemArray[1], dr.ItemArray[6], dr.ItemArray[4], dr.ItemArray[5], dr.ItemArray[8], dr.ItemArray[10], dr.ItemArray[13] });
            }
        }
        private async void btnTeam1_Click(object sender, EventArgs e)// send members and teams to web database
        {
            Button tmpBtn = (Button)sender;

            tmpBtn.Enabled = false;
            if (string.IsNullOrWhiteSpace(txtTournament.Text) || btnTournament.Enabled == true)
            {
                MessageBox.Show("Please name a tournament before you add/update it.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tmpBtn.Enabled = true;
            }
            foreach (Control g in tmpBtn.Parent.Controls)// for loop to look all datas
            {
                if (g is GroupBox)
                {
                    int columnCount = 0;
                    DataGridViewRowCollection rows = table.board.Rows;
                    teamCount = Convert.ToInt32(table.board.RowCount) + 1;
                    object[] contains = new object[12];
                    contains[columnCount] = Convert.ToString(teamCount);
                    columnCount++;
                    foreach (Control c in g.Controls)// add all the details to the database and the datagridview in score board
                    {
                        if (c is TextBox)
                        {
                            if (String.IsNullOrWhiteSpace(c.Text))
                            {
                                MessageBox.Show("Please name a team or fill in names of all members.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                tmpBtn.Enabled = true;
                                break;
                            }
                            else
                            {
                                if (c.Tag.Equals("1"))// if is team name
                                {
                                    Team team = new Team(c.Text);
                                    contains[columnCount] = team.name; //add team name to scoreboard
                                    columnCount++;
                                    for (int i = 0; i < 5; i++)        // all records set to 0
                                    {
                                        contains[columnCount] = 0;
                                        columnCount++;
                                    }
                                    string result = await ApiHandler.addTeam(tournamentID, team);

                                    team = ApiHandler.jsonTo <Team>(result);

                                    teamID = team.id;
                                }
                                else
                                {
                                    Player player = new Player(c.Text);// add all players
                                    contains[columnCount] = player.name;
                                    await ApiHandler.addPlayer(teamID, player);
                                }
                            }
                        }
                    }
                    rows.Add(contains);//add to the datagridview
                }
            }
            tmpBtn.Enabled        = true;
            btnTournament.Enabled = true;
            table.Show();// show the score board with teams you have
        }
Пример #11
0
        void salvarDataSet()
        {
            FolderBrowserDialog oDialog = new FolderBrowserDialog();

            oDialog.RootFolder   = Environment.SpecialFolder.MyComputer;// = Directory.GetCurrentDirectory();
            oDialog.SelectedPath = Directory.GetParent(Directory.GetCurrentDirectory()) + "\\Dados";

            if (oDialog.ShowDialog() == DialogResult.OK)
            {
                string fileXML = oDialog.SelectedPath;

                DataTable oDataTable             = new DataTable();
                DataSet   oDataSet               = new DataSet();
                DataGridViewRowCollection tweets = dataGridViewSearchTwieet.Rows;

                oDataTable.TableName = "Search" + cmbSize.SelectedItem + "Resultados";

                foreach (DataGridViewColumn col in dataGridViewSearchTwieet.Columns)
                {
                    oDataTable.Columns.Add(col.HeaderText);
                }


                //oDataTable.Rows = (DataGridViewColumn)dataGridViewSearchTwieet.Rows;

                try
                {
                    foreach (DataGridViewRow row in tweets)
                    {
                        DataRow dRow = oDataTable.NewRow();

                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            dRow[cell.ColumnIndex] = cell.Value;
                        }

                        oDataTable.Rows.Add(dRow);
                    }


                    /*foreach (DataGridViewRow row in dataGridViewSearchTwieet.Rows)
                     * {
                     *  DataRow dRow = oDataTable.NewRow();
                     *
                     *
                     *  foreach (DataGridViewCell cell in row.Cells)
                     *  {
                     *      dRow[cell.ColumnIndex] = cell.Value;
                     *  }
                     *
                     *  oDataTable.Rows.Add(dRow);
                     * }*/
                }
                catch (Exception e1)
                {
                    Console.WriteLine(e1.InnerException);
                }

                oDataSet.Tables.Add(oDataTable);

                oDataSet.WriteXml(fileXML + "\\" + oDataTable.TableName + ".xml");
            }


            ///
        }
        /// <inheritdoc />
        public void ShowSettings(DataGridViewRowCollection rows)
        {
            // title
            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(new DataGridViewTitleCell()
            {
                LeftColumn = 0, RightColumn = 3, Title = String.Format("Varible of {0}", VariableTypeHelper.FriendlyName(Variable.VariableType))
            });
            row.Cells[row.Cells.Count - 1].ReadOnly = true;
            row.Cells.Add(new DataGridViewTitleCell()
            {
                LeftColumn = 0, RightColumn = 3
            });
            row.Cells[row.Cells.Count - 1].ReadOnly = true;
            row.Cells.Add(new DataGridViewTitleCell()
            {
                LeftColumn = 0, RightColumn = 3
            });
            row.Cells[row.Cells.Count - 1].ReadOnly = true;
            row.Cells.Add(new DataGridViewTitleCell()
            {
                LeftColumn = 0, RightColumn = 3
            });
            row.Cells[row.Cells.Count - 1].ReadOnly = true;

            rows.Add(row);

            // name
            if (Variable.NamedVariable != null)
            {
                if (nameVar == null)
                {
                    nameVar = new StringVar()
                    {
                        Value = Variable.NamedVariable.Name
                    };
                }

                row = new DataGridViewRow();

                row.Cells.Add(new DataGridViewDisableCheckBoxCell()
                {
                    Enabled = false
                });
                row.Cells.Add(new DataGridViewTextBoxCell()
                {
                    Value = "Name"
                });
                row.Cells.Add(nameVar.GetGridCell());
                row.Cells[row.Cells.Count - 1].ReadOnly = true;
                row.Cells.Add(new DataGridViewTextBoxCell()
                {
                    Value = ""
                });

                rows.Add(row);
            }

            // value
            row = new DataGridViewRow();

            row.Cells.Add(new DataGridViewDisableCheckBoxCell()
            {
                Enabled = false
            });
            row.Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = "Value"
            });
            row.Cells.Add(Variable.Value.GetGridCell());
            row.Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = VariableTypeHelper.FriendlyName(Variable.VariableType)
            });

            rows.Add(row);

            // comment
            if (commentVar == null)
            {
                commentVar = new StringVar()
                {
                    Value = Variable.Comment
                };
                commentVar.ValueChanged += (object sender, EventArgs e) => { Variable.Comment = commentVar.Value; };
            }

            row = new DataGridViewRow();

            row.Cells.Add(new DataGridViewDisableCheckBoxCell()
            {
                Enabled = false
            });
            row.Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = "Comment"
            });
            row.Cells.Add(commentVar.GetGridCell());
            row.Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = VariableTypeHelper.FriendlyName(commentVar.VariableType)
            });

            rows.Add(row);
        }
Пример #13
0
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            String name = null;


            try
            {
                textBoxAction.Text = "Loading";
                this.Refresh();

                Log.Debug("Loading all channels from the tvguide[s]");
                // used for partial matches
                TstDictionary guideChannels = new TstDictionary();

                Dictionary <string, Channel> guideChannelsExternald = new Dictionary <string, Channel>();

                List <Channel> lstTvGuideChannels = readChannelsFromTVGuide();

                if (lstTvGuideChannels == null)
                {
                    return;
                }

                // convert to Dictionary
                foreach (Channel ch in lstTvGuideChannels)
                {
                    string tName = ch.DisplayName.Replace(" ", "").ToLowerInvariant();
                    if (!guideChannels.ContainsKey(tName))
                    {
                        guideChannels.Add(tName, ch);
                    }

                    // used to make sure that the available mapping is used by default
                    if (ch.ExternalId != null && !ch.ExternalId.Trim().Equals(""))
                    {
                        // need to check this because we can have channels with multiple display-names
                        // and they're currently handles as one channel/display-name.
                        // only in the mapping procedure of course
                        if (!guideChannelsExternald.ContainsKey(ch.ExternalId))
                        {
                            guideChannelsExternald.Add(ch.ExternalId, ch);
                        }
                    }
                }

                Log.Debug("Loading all channels from the database");

                CBChannelGroup chGroup = (CBChannelGroup)comboBoxGroup.SelectedItem;

                IList <Channel> channels;

                bool loadRadio = checkBoxLoadRadio.Checked;

                if (chGroup != null && chGroup.idGroup != -1)
                {
                    SqlBuilder   sb1           = new SqlBuilder(Gentle.Framework.StatementType.Select, typeof(Channel));
                    SqlStatement stmt1         = sb1.GetStatement(true);
                    SqlStatement ManualJoinSQL = new SqlStatement(stmt1.StatementType, stmt1.Command,
                                                                  String.Format(
                                                                      "select c.* from Channel c join GroupMap g on c.idChannel=g.idChannel where " +
                                                                      (loadRadio ? "" : " c.isTv = 1 and ") +
                                                                      " g.idGroup = '{0}' order by g.sortOrder", chGroup.idGroup),
                                                                  typeof(Channel));
                    channels = ObjectFactory.GetCollection <Channel>(ManualJoinSQL.Execute());
                }
                else
                {
                    SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Channel));
                    sb.AddOrderByField(true, "sortOrder");
                    if (!loadRadio)
                    {
                        sb.AddConstraint(" isTv = 1");
                    }
                    SqlStatement stmt = sb.GetStatement(true);
                    channels = ObjectFactory.GetCollection <Channel>(stmt.Execute());
                }

                progressBar1.Minimum = 0;
                progressBar1.Maximum = channels.Count;
                progressBar1.Value   = 0;

                dataGridChannelMappings.Rows.Clear();

                int row = 0;

                if (channels.Count == 0)
                {
                    MessageBox.Show("No tv-channels available to map");
                    return;
                }
                // add as many rows in the datagrid as there are channels
                dataGridChannelMappings.Rows.Add(channels.Count);

                DataGridViewRowCollection rows = dataGridChannelMappings.Rows;

                // go through each channel and try to find a matching channel
                // 1: matching display-name (non case-sensitive)
                // 2: partial search on the first word. The first match will be selected in the dropdown

                foreach (Channel ch in channels)
                {
                    Boolean         alreadyMapped = false;
                    DataGridViewRow gridRow       = rows[row++];

                    DataGridViewTextBoxCell  idCell          = (DataGridViewTextBoxCell)gridRow.Cells["Id"];
                    DataGridViewTextBoxCell  channelCell     = (DataGridViewTextBoxCell)gridRow.Cells["tuningChannel"];
                    DataGridViewTextBoxCell  providerCell    = (DataGridViewTextBoxCell)gridRow.Cells["tuningChannel"];
                    DataGridViewCheckBoxCell showInGuideCell = (DataGridViewCheckBoxCell)gridRow.Cells["ShowInGuide"];

                    channelCell.Value     = ch.DisplayName;
                    idCell.Value          = ch.IdChannel;
                    showInGuideCell.Value = ch.VisibleInGuide;

                    DataGridViewComboBoxCell guideChannelComboBox = (DataGridViewComboBoxCell)gridRow.Cells["guideChannel"];

                    // always add a empty item as the first option
                    // these channels will not be updated when saving
                    guideChannelComboBox.Items.Add("");

                    // Start by checking if there's an available mapping for this channel
                    Channel matchingGuideChannel = null;

                    if (guideChannelsExternald.ContainsKey(ch.ExternalId))
                    {
                        matchingGuideChannel = guideChannelsExternald[ch.ExternalId];
                        alreadyMapped        = true;
                    }
                    // no externalid mapping available, try using the name
                    if (matchingGuideChannel == null)
                    {
                        string tName = ch.DisplayName.Replace(" ", "").ToLowerInvariant();
                        if (guideChannels.ContainsKey(tName))
                        {
                            matchingGuideChannel = (Channel)guideChannels[tName];
                        }
                    }

                    Boolean exactMatch   = false;
                    Boolean partialMatch = false;

                    if (!alreadyMapped)
                    {
                        if (matchingGuideChannel != null)
                        {
                            exactMatch = true;
                        }
                        else
                        {
                            // No name mapping found

                            // do a partial search, default off
                            if (checkBoxPartialMatch.Checked)
                            {
                                // do a search using the first word(s) (skipping the last) of the channelname
                                name = ch.DisplayName.Trim();
                                int spaceIdx = name.LastIndexOf(" ");
                                if (spaceIdx > 0)
                                {
                                    name = name.Substring(0, spaceIdx).Trim();
                                }
                                else
                                {
                                    // only one word so we'll do a partial match on the first 3 letters
                                    if (name.Length > 3)
                                    {
                                        name = name.Substring(0, 3);
                                    }
                                }

                                try
                                {
                                    // Note: the partial match code doesn't work as described by the author
                                    // so we'll use PrefixMatch method (created by a codeproject user)
                                    ICollection partialMatches = guideChannels.PrefixMatch(name.Replace(" ", "").ToLowerInvariant());

                                    if (partialMatches != null && partialMatches.Count > 0)
                                    {
                                        IEnumerator pmE = partialMatches.GetEnumerator();
                                        pmE.MoveNext();
                                        matchingGuideChannel = (Channel)guideChannels[(string)pmE.Current];
                                        partialMatch         = true;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Log.Error("Error while searching for matching guide channel :" + ex.Message);
                                }
                            }
                        }
                    }
                    // add the channels
                    // set the first matching channel in the search above as the selected

                    Boolean gotMatch = false;

                    string ALREADY_MAPPED = "Already mapped (got external id)";
                    string EXACT_MATCH    = "Exact match";
                    string PARTIAL_MATCH  = "Partial match";
                    string NO_MATCH       = "No match";

                    DataGridViewCell cell = gridRow.Cells["matchType"];

                    foreach (DictionaryEntry de in guideChannels)
                    {
                        Channel guideChannel = (Channel)de.Value;

                        String itemText = guideChannel.DisplayName + " (" + guideChannel.ExternalId + ")";

                        guideChannelComboBox.Items.Add(itemText);

                        if (!gotMatch && matchingGuideChannel != null)
                        {
                            if (guideChannel.DisplayName.ToLowerInvariant().Equals(matchingGuideChannel.DisplayName.ToLowerInvariant()))
                            {
                                // set the matchtype row color according to the type of match(already mapped,exact, partial, none)
                                if (alreadyMapped)
                                {
                                    cell.Style.BackColor = Color.White;
                                    cell.ToolTipText     = ALREADY_MAPPED;
                                    // hack so that we can order the grid by mappingtype
                                    cell.Value = "";
                                }
                                else if (exactMatch)
                                {
                                    cell.Style.BackColor = Color.Green;
                                    cell.ToolTipText     = EXACT_MATCH;
                                    cell.Value           = "  ";
                                }
                                else if (partialMatch)
                                {
                                    cell.Style.BackColor = Color.Yellow;
                                    cell.ToolTipText     = PARTIAL_MATCH;
                                    cell.Value           = "   ";
                                }

                                guideChannelComboBox.Value = itemText;
                                guideChannelComboBox.Tag   = ch.ExternalId;

                                gotMatch = true;
                            }
                        }
                    }
                    if (!gotMatch)
                    {
                        cell.Style.BackColor = Color.Red;
                        cell.ToolTipText     = NO_MATCH;
                        cell.Value           = "    ";
                    }
                    progressBar1.Value++;
                }
                textBoxAction.Text = "Finished";
            }
            catch (Exception ex)
            {
                Log.Error("Failed loading channels/mappings : channel {0} erro {1} ", name, ex.Message);
                Log.Error(ex.StackTrace);
                textBoxAction.Text = "Error";
            }
        }
Пример #14
0
        public void ByLisencePlate(licensePlatePrefix licensePlatePrefix, DataGridView dgv)
        {
            DataGridViewRowCollection collection = dgv.Rows;

            dgv.CurrentCell = null;

            int counter = 0;

            for (int i = 0; i < Administrator.listaVehiculos.Count; i++)
            {
                collection[i].Visible = true;

                licensePlatePrefixLevel prefixLevel = GetLicensePlatePrefixLevel(licensePlatePrefix);

                #region For two and three cases

                string licensePlatePrefixString = licensePlatePrefix.ToString();

                #endregion

                switch (prefixLevel)
                {
                case licensePlatePrefixLevel.one:

                    char licensePlatePrefixChar = Convert.ToChar(licensePlatePrefix.ToString());

                    if (licensePlatePrefixChar != Administrator.listaVehiculos[i].LicensePlate[0])
                    {
                        collection[i].Visible = false;
                        counter++;
                    }

                    break;

                case licensePlatePrefixLevel.two:

                    string licenPlaceFirstTwoChars
                        = Administrator.listaVehiculos[i].LicensePlate[0].ToString()
                          + Administrator.listaVehiculos[i].LicensePlate[1].ToString();

                    if (licensePlatePrefixString != licenPlaceFirstTwoChars)
                    {
                        collection[i].Visible = false;
                        counter++;
                    }

                    break;

                case licensePlatePrefixLevel.tree:

                    string licenPlaceFirstThreeChars
                        = Administrator.listaVehiculos[i].LicensePlate[0].ToString()
                          + Administrator.listaVehiculos[i].LicensePlate[1].ToString()
                          + Administrator.listaVehiculos[i].LicensePlate[2].ToString();

                    if (licensePlatePrefixString != licenPlaceFirstThreeChars)
                    {
                        collection[i].Visible = false;
                        counter++;
                    }

                    break;
                }
            }
        }
Пример #15
0
 public PrintDataGrid(DataGridViewRowCollection rowCollection)
 {
     this.rowColl = rowCollection;
 }
Пример #16
0
        private void Get_Data(String user_name, String Date)
        {
            DataGridViewRowCollection DGVR = dataGridView_workinfo.Rows;
            ArrayList  OnDutyDate          = new ArrayList();
            ArrayList  OnDutyTime          = new ArrayList();
            ArrayList  OffDutyTime         = new ArrayList();
            ArrayList  Single_Total        = new ArrayList();
            ArrayList  Sum       = new ArrayList();
            List <int> Total     = new List <int>();
            ArrayList  Check     = new ArrayList();
            int        Total_SUM = 0;

            DGVR.Clear();

            String SQL_CMD = "Select OnDutyDate,OnDutyTime,OffDutyTime,Single_total,Check From " + user_name + " WHERE OnDutyDate LIKE '" + Date + "%'";

            //"SELECT Meal,Date,nop FROM meal WHERE name LIKE" + "'" + show_customer_LbSelected + "'";
            FL_OLE.conn.Open();
            cmd.Connection  = FL_OLE.conn;
            cmd.CommandText = SQL_CMD;

            dr = cmd.ExecuteReader();


            while (dr.Read())
            {
                OnDutyDate.Add(dr[0]);
                OnDutyTime.Add(dr[1]);
                OffDutyTime.Add(dr[2]);
                Single_Total.Add(dr[3]);
                Check.Add(dr[4]);
                // DGVR.Add(dr[0],dr[1], dr[2], dr[3],dr[4]);
            }

            if (OnDutyDate.Count == 0)
            {
                DGVR.Add("無資料", "無資料", "無資料", "無資料", "無資料");
            }
            else
            {
                //foreach (String all in Single_Total)//處理型態要轉換時間顯示
                //{

                //    Total.Add(Int32.Parse(all));
                //}
                for (int k = 0; k < Single_Total.Count; k++)
                {
                    if (Single_Total[k].ToString() == "")
                    {
                        break;
                    }
                    else
                    {
                        Total.Add(Int32.Parse(Single_Total[k].ToString()));
                    }
                }
                for (int i = 0; i < Total.Count; i++)
                {
                    Total_SUM += Total[i];
                    Sum.Add(change2Hour(Total[i]).ToString());
                    textBox1.Text += " 轉型態 : " + change2Hour(Total[i]).ToString();
                }
                textBox1.Text += OnDutyDate.Count + " " + OnDutyTime.Count + " " + OffDutyTime.Count + " " + Sum.Count + " " + Check.Count;
                try
                {
                    if (Sum.Count < OnDutyDate.Count)
                    {
                        for (int j = 0; j < OnDutyDate.Count; j++)
                        {
                            //55545問題解決
                            if (j == OnDutyDate.Count - 1)
                            {
                                DGVR.Add(OnDutyDate[j], OnDutyTime[j], "尚未打卡下班", "無資料", "無資料");
                                MessageBox.Show("缺少打卡下班\r\n請管理者補打下班卡\r\n", "警告訊息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                DGVR.Add(OnDutyDate[j], OnDutyTime[j], OffDutyTime[j], Sum[j], Check[j]);
                            }
                        }
                    }
                    else
                    {
                        for (int j = 0; j < OnDutyDate.Count; j++)
                        {
                            DGVR.Add(OnDutyDate[j], OnDutyTime[j], OffDutyTime[j], Sum[j], Check[j]);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("[ 缺少打卡下班 ]\r\n請老闆補打下班卡\r\n才會顯示之後打卡資料\r\n", "提醒訊息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            FL_OLE.conn.Close();
            label_sum.Text = "總時數為 : " + change2Hour(Total_SUM);
        }
        /// <inheritdoc />
        public void ShowSettings(DataGridViewRowCollection rows)
        {
            row = new DataGridViewRow();

            DataGridViewDisableCheckBoxCell visibleCell = new DataGridViewDisableCheckBoxCell()
            {
                Value = VariableNodeSocket.Visible, Enabled = VariableNodeSocket.Connections.Count == 0
            };

            visibleCell.ValueChanged += (object sender, EventArgs e) =>
            {
                VariableNodeSocket.Visible = (bool)visibleCell.Value;
                if (!VariableNodeSocket.Visible && VariableNodeSocket.Connections.Count != 0)
                {
                    VariableNodeSocket.Visible = true;
                }
                else
                {
                    Node.Refresh();
                }
            };
            row.Cells.Add(visibleCell);

            row.Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = VariableNodeSocket.Name
            });

            // variable in
            if (VariableNodeSocket.Type == NodeSocketType.VariableIn)
            {
                if (VariableNodeSocket.Connections.Count == 0)
                {
                    // edit value
                    if (!VariableNodeSocket.NodeSocketData.CanBeEmpty)
                    {
                        row.Cells.Add(VariableNodeSocket.Value.GetGridCell());
                    }
                    // only connection is possible
                    else
                    {
                        row.Cells.Add(new DataGridViewTextBoxCell()
                        {
                            Value = "(connection-only)"
                        });
                        row.Cells[row.Cells.Count - 1].ReadOnly = true;
                    }
                }
                // socket used
                else
                {
                    row.Cells.Add(new DataGridViewTextBoxCell()
                    {
                        Value = "(socket used)"
                    });
                    row.Cells[row.Cells.Count - 1].ReadOnly = true;
                }
            }
            // variable out
            else
            {
                row.Cells.Add(new DataGridViewTextBoxCell()
                {
                    Value = "(read-only)"
                });
                row.Cells[row.Cells.Count - 1].ReadOnly = true;
            }

            row.Cells.Add(new DataGridViewTextBoxCell()
            {
                Value = VariableTypeHelper.FriendlyName(VariableNodeSocket.VariableType)
            });

            rows.Add(row);
        }
Пример #18
0
        private void btnParse_Click(object sender, EventArgs e)
        {
            try
            {
                string FileToLoad = Base_Folder_Path + comboBoxFileSelect.Items[comboBoxFileSelect.SelectedIndex].ToString();

                if (File.Exists(FileToLoad))
                {
                    if (chkParseParam.Checked || textBoxRE.Text != "")
                    {
                        // make sure that all the data is gone before continuing
                        dataGridView1.Columns.Clear();

                        StreamReader sr      = new StreamReader(FileToLoad, (System.Text.Encoding.GetEncoding(1252)));
                        string       ToParse = sr.ReadToEnd();

                        Regex           temprx;
                        MatchCollection tmatches;
                        String          WideCondition   = "";
                        String          NarrowCondition = "";

                        // Use built in REexpression
                        if (chkParseParam.Checked)
                        {
                            // First parse out what we need from the selection box
                            temprx = new Regex(@"\d\)\s(?<sename>.*)\s-\s(?<pname>.*).txt");
                            Match tmatch = temprx.Match(comboBoxFileSelect.Items[comboBoxFileSelect.SelectedIndex].ToString());

                            // Now Assign the correct RE
                            NarrowCondition = tmatch.Groups["sename"].ToString();
                            WideCondition   = tmatch.Groups["pname"].ToString();

                            temprx = p_DailyR.GetRESubExpression(NarrowCondition); //, tmatch.Groups["pname"].ToString());
                        }
                        else
                        {
                            temprx = new Regex(@textBoxRE.Text);
                        }

                        string[] Groups     = temprx.GetGroupNames();
                        int      noOfGroups = 0;    // we don't need digit groups

                        // first calculate the number of non-digit groups
                        foreach (string str in Groups)
                        {
                            if (!char.IsDigit(str, 0))
                            {
                                ++noOfGroups;
                            }
                        }

                        System.Windows.Forms.DataGridViewTextBoxColumn dl = new System.Windows.Forms.DataGridViewTextBoxColumn();
                        dl.HeaderText = "LineNumber";
                        dl.Name       = "LineNumber";
                        dl.FillWeight = 25;
                        this.dataGridView1.Columns.Add(dl);

                        // Now calculate and draw out the column headers and  group names
                        ArrayList grouplist = new ArrayList();
                        foreach (string str in Groups)
                        {
                            // we only want to show named groups
                            if (!char.IsDigit(str, 0))
                            {
                                System.Windows.Forms.DataGridViewTextBoxColumn dg = new System.Windows.Forms.DataGridViewTextBoxColumn();
                                dg.HeaderText = str;
                                dg.Name       = str;
                                dg.FillWeight = (100 / noOfGroups);
                                this.dataGridView1.Columns.Add(dg);
                                grouplist.Add(str);
                            }
                        }

                        // Now Parse the TextFile and we'll see what happens yeah! :)
                        tmatches = temprx.Matches(ToParse);

                        string[] tstring = new string[(noOfGroups + 1)];
                        DataGridViewRowCollection rows = this.dataGridView1.Rows;
                        int it = 1;

                        foreach (Match tmatch in tmatches)
                        {
                            tstring[0] = it.ToString();
                            // we don't need group 0
                            for (int i = 1; i < (noOfGroups + 1); ++i)
                            {
                                string groupname = grouplist[i - 1].ToString();

                                if (chkParseParam.Checked)
                                {
                                    Parser pr = p_DailyR.get_Parser_pointer;

                                    PropertyDetails pd = new PropertyDetails();
                                    Match           t  = tmatch;
                                    pr.ParsePropertyDetail(ref t, WideCondition, NarrowCondition, ref pd);

                                    if (groupname == "addr")
                                    {
                                        tstring[i] = pd.Address;
                                    }
                                    else if (groupname == "city")
                                    {
                                        tstring[i] = pd.City;
                                    }
                                    else if (groupname == "zip")
                                    {
                                        tstring[i] = pd.ZipCode.ToString();
                                    }
                                    else
                                    {
                                        tstring[i] = tmatch.Groups[groupname].ToString();
                                    }
                                }
                                else
                                {
                                    tstring[i] = tmatch.Groups[groupname].ToString();
                                }
                            }
                            ++it;
                            rows.Add(tstring);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Enter Regular Expression");
                    }
                }
            }
            catch (Exception eC)
            {
                MessageBox.Show("Regulare Expression Error - " + eC.Message);
            }
        }
Пример #19
0
/*
 * --------------------------------------------------------------------------------------------
 * IMPLEMENTATION TO BE USED IN LAB 2.
 * --------------------------------------------------------------------------------------------
 */

        // Here you need to implement your own methods that call the stored procedures
        // addStudent and addStudentPhoneNo
        public bool CallSPAddStudent(string studentID, string firstName, string lastName, string gender, string streetAddress, string zipCode, string city, string country, string birthDate, string studentType, DataGridViewRowCollection phoneEntries)
        {
            if (studentID.Length == 0 || studentID.Length > 8)
            {
                MessageBox.Show("Error: Incorrect student ID", "Data validation error");
                return(false);
            }

            if (firstName.Length == 0 || firstName.Length > 50)
            {
                MessageBox.Show("Error: Incorrect first name", "Data validation error");
                return(false);
            }

            if (lastName.Length == 0 || lastName.Length > 50)
            {
                MessageBox.Show("Error: Incorrect last name", "Data validation error");
                return(false);
            }

            if (gender != "male" && gender != "female")
            {
                MessageBox.Show("Error: Incorrect gender", "Data validation error");
                return(false);
            }

            if (streetAddress.Length > 100)
            {
                MessageBox.Show("Error: Incorrect street address", "Data validation error");
                return(false);
            }

            if (city.Length == 0 || city.Length > 50)
            {
                MessageBox.Show("Error: Incorrect city", "Data validation error");
                return(false);
            }

            if (country.Length == 0 || country.Length > 50)
            {
                MessageBox.Show("Error: Incorrect country", "Data validation error");
                return(false);
            }

            if (studentType.Length == 0 || studentType.Length > 50)
            {
                MessageBox.Show("Error: Incorrect student type", "Data validation error");
                return(false);
            }

            for (int i = 0; i < phoneEntries.Count - 1; i++)
            {
                if ((String)phoneEntries[i].Cells[0].Value == null)
                {
                    MessageBox.Show($"Error: Type is missing for phone number field no. {i + 1}.", "Data validation error");
                    return(false);
                }
                else if ((String)phoneEntries[i].Cells[1].Value == null)
                {
                    MessageBox.Show($"Error: Number is missing for phone number field no. {i + 1}.", "Data validation error");
                    return(false);
                }
            }

            int rowsAffected;

            // Call the stored procedure
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                SqlCommand cmd = new SqlCommand("addStudent", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@StudentID", studentID);
                cmd.Parameters.AddWithValue("@FirstName", firstName);
                cmd.Parameters.AddWithValue("@LastName", lastName);
                cmd.Parameters.AddWithValue("@Gender", gender);
                cmd.Parameters.AddWithValue("@StreetAddress", streetAddress);
                cmd.Parameters.AddWithValue("@ZipCode", zipCode);
                cmd.Parameters.AddWithValue("@City", city);
                cmd.Parameters.AddWithValue("@Country", country);
                cmd.Parameters.AddWithValue("@BirthDate", birthDate);
                cmd.Parameters.AddWithValue("@StudentType", studentType);

                rowsAffected = cmd.ExecuteNonQuery();

                for (int i = 0; i < phoneEntries.Count - 1; i++)
                {
                    cmd             = new SqlCommand("addStudentPhoneNo", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@studentID", studentID);

                    cmd.Parameters.AddWithValue("@phoneType", (String)phoneEntries[i].Cells[0].Value);
                    cmd.Parameters.AddWithValue("@number", (String)phoneEntries[i].Cells[1].Value);

                    cmd.ExecuteNonQuery();
                }
            } catch (SqlException exception)
            {
                // non-unique StudentID
                if (exception.Number == 2627)
                {
                    MessageBox.Show("Error: Student with this ID already exists", "Primary key violation");
                }
                else
                {
                    MessageBox.Show($"Error: {exception.Message}", "SQL Error");
                }
                con.Close();
                return(false);
            }

            con.Close();
            return(rowsAffected > 0);
        }
Пример #20
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!validacion())
            {
                return;
            }

            entradasmat c = new entradasmat();

            c.nsis   = this.textBox1.Text.Trim();
            c.nrec   = this.textBox2.Text.Trim();
            c.fech   = this.dateTimePicker1.Value;
            c.prov   = this.comboBox3.SelectedValue.ToString();
            c.mat    = this.comboBox2.SelectedValue.ToString();
            c.equ    = this.textBox3.Text.Trim();
            c.ope    = this.textBox14.Text.Trim();
            c.rkm    = Convert.ToDecimal(this.textBox4.Text.Trim());
            c.volm   = Convert.ToDecimal(this.textBox5.Text.Trim());
            c.cosm   = Convert.ToDecimal(this.textBox6.Text.Trim());
            c.flem   = Convert.ToDecimal(this.textBox7.Text.Trim());
            c.ttra   = this.comboBox1.SelectedValue.ToString();
            c.matfle = Convert.ToDecimal(c.Matfle);
            c.tifkm  = Convert.ToDecimal(c.Tifkm);
            c.timat  = Convert.ToDecimal(c.Timat);
            c.hfin   = this.maskedTextBox2.Text;
            c.hini   = this.maskedTextBox1.Text;
            c.dcarg  = this.comboBox4.SelectedValue.ToString();
            c.usu    = Operaciones.op_var.usu;

            TimeSpan a = TimeSpan.Parse(c.hfin) - TimeSpan.Parse(c.hini);

            this.label5.Text = "Tiempo de Respuesta: " + a.ToString();
            //this.label15.Text = String.Format("{0:0.00}",c.matfle);
            //this.textBox10.Text =String.Format("{0:0.00}", c.tifkm);
            //this.textBox11.Text=String.Format("{0:0.00}",c.timat);
            //c.matfle = Convert.ToDecimal(this.label15.Text.Trim());
            //c.tifkm = Convert.ToDecimal(this.textBox10.Text.Trim());
            //c.timat = Convert.ToDecimal(this.textBox11.Text.Trim());

            dataGridView1.Visible = true;
            DataGridViewRowCollection dr = dataGridView1.Rows;

            dr.Clear();
            dr.Add("INGRESO POR FLETE - KM", c.tifkm.ToString("c"));
            dr.Add("INGRESO POR MATERIAL", c.timat.ToString("c"));
            dr.Add("TOTAL", c.matfle.ToString("c"));

            int rowsAffected = 0;

            if (string.IsNullOrEmpty(_id))
            {
                rowsAffected = op_entradasmat.accion(c, 1);
            }
            else
            {
                this.textBox1.ReadOnly = true;
                //this.textBox12.ReadOnly = true;
                rowsAffected = op_entradasmat.accion(c, 2);
            }

            if (rowsAffected > 0)
            {
                if (rowsAffected == 1)
                {
                    MessageBox.Show(mensajes.MsjProc1, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operacion();
                    this.toolStripButton3.Visible = true;
                    this.toolStripButton1.Visible = false;
                }
                if (rowsAffected == 2)
                {
                    MessageBox.Show(mensajes.MsjProc2, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operacion();
                    this.toolStripButton3.Visible = true;
                    this.toolStripButton1.Visible = false;
                }
                if (rowsAffected == 3)
                {
                    MessageBox.Show(mensajes.MsjProc3, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (rowsAffected == 4)
                {
                    if (MessageBox.Show(mensajes.MsjProc4 + " " + mensajes.MsjProc5, Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        rowsAffected = op_entradasmat.accion(c, 2);
                    }
                }
            }
            else
            {
                MessageBox.Show(mensajes.MsjProc0, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }


            //this.label10.Text = "EMPLEADO: " + c.NombreCompleto;
        }
        ///<summary>
        /// 修改节点时需要调用的传值方法
        ///</summary>

        public void modify()
        {
            DisplayName.Text = Basic[0];

            if (Basic[1] != "")
            {
                MColorChange            = true;
                ModuleColorRGB          = StrToRGB(Basic[1]);
                ModuleOfColor.BackColor = Color.FromArgb(ModuleColorRGB[1], ModuleColorRGB[2], ModuleColorRGB[3]);
            }
            else
            {
                ModuleOfColor.BackColor = tabPage1.BackColor;
            }

            ModuleSort.Text = Basic[2];

            ModuleName.Text = Basic[3];

            if (Basic[4] != "")
            {
                TColorChange          = true;
                TextColorRGB          = StrToRGB(Basic[4]);
                TextOfColor.BackColor = Color.FromArgb(TextColorRGB[1], TextColorRGB[2], TextColorRGB[3]);
            }
            else
            {
                TextOfColor.BackColor = tabPage1.BackColor;
            }

            OutputName.Text = Basic[5];

            this.InputInfo = Basic[6];
            if (Basic[6].Split(';').Length > 1)
            {
                string[]      temp     = Basic[6].Split(';');
                List <string> tempInfo = new List <string>();
                foreach (string info in temp)
                {
                    tempInfo.Add(info.Split(',')[0]);
                }
                InputName.Text = String.Join(",", tempInfo.ToArray());
            }
            else
            {
                InputName.Text = Basic[6];//输入初值信息20090616
            }
            ControlTacticName.Text = Basic[7];

            DataGridViewRowCollection rows = this.dataGridView1.Rows;

            for (int i = 0; i < index2; i++)
            {
                rows.Add(function[i, 0], function[i, 1], function[i, 2], function[i, 3], function[i, 4],
                         function[i, 5], function[i, 6], function[i, 7], function[i, 8], function[i, 9]);
            }

            OtherInfo = code;
            infoName.SelectedIndex = 0;
            infoText.Text          = code[0];

            if (index2 == 0)//没有功能属性
            {
                DeleteFunction.Enabled = false;
                ModifyFunction.Enabled = false;
            }
            if (FirstTime == true)
            {
                Savemode  = true;
                FirstTime = false;
            }
        }
Пример #22
0
        private void frmmovimientosdetEXT_Load(object sender, EventArgs e)
        {
            //textBox7.Text = op_sql.parametro1("Select flete from conf_transp");
            IntPtr hmenu = GetSystemMenu(this.Handle, 0);
            int    cnt   = GetMenuItemCount(hmenu);

            // remove 'close' action
            RemoveMenu(hmenu, cnt - 1, MF_DISABLED | MF_BYPOSITION);
            // remove extra menu line
            RemoveMenu(hmenu, cnt - 2, MF_DISABLED | MF_BYPOSITION);
            DrawMenuBar(this.Handle);

            //int hora=DateTime.Now.Hour;
            //int minuto = DateTime.Now.Minute;
            //maskedTextBox1.Text = DateTime.Now.Hour();
            textBox1.Text = op_sql.parametro("Select num from tmpautonumerico where tabla=@tabla", "tabla", "entmat").PadLeft(10, '0');

            //textBox12.Text = DateTime.Now.ToShortDateString();

            comboBox3.DataSource    = op_combos.FillCombo("select cod, nom from proveedores order by 2");
            comboBox3.DisplayMember = "nom";
            comboBox3.ValueMember   = "cod";
            comboBox3.Text          = null;

            comboBox4.DataSource    = op_combos.FillCombo("select idproy as cod, nomproy as nom from proyectos where  activo=1 order by 2");
            comboBox4.DisplayMember = "nom";
            comboBox4.ValueMember   = "cod";
            comboBox4.Text          = null;


            comboBox1.DataSource    = op_documentos.transaccion();
            comboBox1.DisplayMember = "nom";
            comboBox1.ValueMember   = "cod";
            comboBox1.Text          = null;


            if (!string.IsNullOrEmpty(_id))
            {
                entradasmat c = op_entradasmat.GellIdentradasmat(_id, 1);
                if (c != null)
                {
                    this.Text                    = "Editando Registro: [Recibo: " + c.nrec + " Equipo: " + c.equ + "]";
                    this.textBox1.Text           = c.nsis;
                    this.textBox2.Text           = c.nrec;
                    this.textBox3.Text           = c.equ;
                    this.textBox7.Text           = c.flem.ToString();
                    this.comboBox2.SelectedValue = c.mat;
                    this.comboBox3.SelectedValue = c.prov;
                    this.comboBox4.SelectedValue = c.dcarg;

                    this.textBox14.Text        = c.ope;
                    this.maskedTextBox2.Text   = c.hfin;
                    this.maskedTextBox1.Text   = c.hini;
                    this.dateTimePicker1.Value = c.fech;
                    this.textBox4.Text         = c.rkm.ToString();
                    this.textBox5.Text         = c.volm.ToString();
                    this.textBox6.Text         = c.cosm.ToString();

                    this.comboBox1.SelectedValue = c.ttra;

                    TimeSpan a = TimeSpan.Parse(c.hfin) - TimeSpan.Parse(c.hini);
                    this.label5.Text      = "Tiempo de Respuesta: " + a.ToString();
                    dataGridView1.Visible = true;
                    DataGridViewRowCollection dr = dataGridView1.Rows;
                    dr.Clear();
                    dr.Add("INGRESO POR FLETE - KM", c.Tifkm.ToString("c"));
                    dr.Add("INGRESO POR MATERIAL", c.Timat.ToString("c"));
                    dr.Add("TOTAL", c.matfle.ToString("c"));

                    this.textBox13.Text      = op_sql.parametro("select nomempl from empleados where codempl=@cod order by 1", "@cod", c.ope);
                    toolStripButton5.Visible = true;
                    toolStripButton1.Visible = false;
                    toolStripButton3.Visible = false;
                    operacion();

                    //foreach (Control u in this.Controls)
                    //{
                    //    if (u is Button)
                    //        u.Enabled = true;
                    //}
                }
            }
            else
            {
                toolStripButton3.Visible = false;
                toolStripButton5.Visible = false;
                toolStripButton1.Visible = true;

                this.label5.Text = null;
                this.Text        = "Nuevo Registro - Entrada de Materiales";
            }

            textBox3.AutoCompleteCustomSource = Operaciones.autocompletar.LoadAutoComplete();
            textBox3.AutoCompleteMode         = AutoCompleteMode.Suggest;
            textBox3.AutoCompleteSource       = AutoCompleteSource.CustomSource;
        }
Пример #23
0
 public ListEditor()
 {
     InitializeComponent();
     listref = listBox.Rows;
 }
 public Frequencia(DataGridViewRowCollection rows, int columnCount)
 {
     this.Rows        = rows;
     this.ColumnCount = columnCount;
 }
Пример #25
0
        private void search_single_staff(excel.Worksheet sheet)
        {
            DataGridViewRowCollection DGVC = dataGridView_check.Rows;
            ArrayList staff_name           = new ArrayList();
            ArrayList staff_OnDuty_Date    = new ArrayList();
            ArrayList staff_OnDuty_Time    = new ArrayList();
            ArrayList staff_OffDuty_Time   = new ArrayList();
            ArrayList staff_check          = new ArrayList();
            ArrayList staff_remark         = new ArrayList();
            ArrayList staff_single         = new ArrayList();
            ArrayList all_time             = new ArrayList();
            ArrayList all_name             = new ArrayList();

            for (int i = 0; i < Input_Employee_2combo.Count; i++)
            {
                staff_single.Clear();
                String SQL_CMD = "Select * From " + Input_Employee_2combo[i].ToString() + " WHERE OnDutyDate LIKE '" + (DateTime.Now.Year - 1911).ToString() + "/"
                                 + (DateTime.Now.Month - 1) + "/%'";
                List <int> count_time   = new List <int>();
                int        total_single = 0;
                FL_OLE.conn.Open();
                cmd.Connection  = FL_OLE.conn;
                cmd.CommandText = SQL_CMD;

                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    staff_name.Add(dr[1]);
                    staff_OnDuty_Date.Add(dr[2]);
                    staff_OnDuty_Time.Add(dr[3]);
                    staff_OffDuty_Time.Add(dr[4]);
                    staff_single.Add(dr[5]);
                    staff_check.Add(dr[6]);
                    staff_remark.Add(dr[7]);

                    // DGVC.Add(Input_Employee_2combo[i].ToString(), "當月無上班資料", "當月無上班資料", "當月無上班資料", "當月無上班資料", "當月無上班資料", "當月無上班資料");

                    DGVC.Add(dr[1], dr[2], dr[3], dr[4], dr[5], dr[6], dr[7]);
                }
                FL_OLE.conn.Close();

                for (int j = 0; j < staff_single.Count; j++)
                {
                    if (staff_single[j].ToString() == "")
                    {
                        count_time.Add(0);
                    }
                    else
                    {
                        count_time.Add(Int32.Parse(staff_single[j].ToString()));
                    }
                }
                for (int k = 0; k < count_time.Count; k++)
                {
                    if (staff_check[k].ToString() != "未審核上班")
                    {
                        total_single += count_time[k];
                    }
                }
                all_name.Add(Input_Employee_2combo[i].ToString());
                all_time.Add("[" + (DateTime.Now.Month - 1) + "月] 時數 : " + FL_OLE.change2Hour(total_single));
                //DGVC.Add("", "", "", "", "", "" ,Input_Employee_2combo[i].ToString() +"[" +(DateTime.Now.Month - 1) + "月] 時數 = "+FL_OLE.change2Hour(total_single));
            }
            //DGVC.Add("", "", "", "員工名字", "總時數統計", "", "");

            sheet.Cells[1, 9]  = "員工名字";
            sheet.Cells[1, 10] = "總時數統計";

            for (int i = 0; i < all_time.Count; i++)
            {
                sheet.Cells[i + 2, 9]  = all_name[i].ToString();
                sheet.Cells[i + 2, 10] = all_time[i].ToString();
                //DGVC.Add("", "", "", all_name[i].ToString(), all_time[i].ToString(), "", "");
            }
            sheet.Cells[all_time.Count + 2, 10] = "※注意 顯示未審核上班 不列入總時數統計";
            //DGVC.Add("", "", "", "", "※注意 顯示未審核上班 不列入總時數統計", "", "");

            sheet.Cells[1, 1] = "姓名";
            sheet.Cells[1, 2] = "上班日期";
            sheet.Cells[1, 3] = "上班時間";
            sheet.Cells[1, 4] = "下班時間";
            sheet.Cells[1, 5] = "單日上班時數(分鐘)";
            sheet.Cells[1, 6] = "上班審核";
            sheet.Cells[1, 7] = "備註";

            for (int l = 0; l < DGVC.Count; l++)
            {
                for (int j = 0; j < dataGridView_check.Columns.Count; j++)
                {
                    string value = dataGridView_check[j, l].Value.ToString();
                    sheet.Cells[l + 2, j + 1] = value;
                }
            }

            sheet.Columns.EntireColumn.AutoFit();
        }
Пример #26
0
        public static void export(DateTime currMonth, DataGridViewRowCollection rows,
                                  string templatePath, string exportPath)
        {
            Excel.Application app = new Excel.Application();
            app.Visible = true; // DEBUG

            Excel.Workbook  workbook = app.Workbooks.Open(templatePath);
            Excel.Worksheet wsheet   = (Excel.Worksheet)workbook.ActiveSheet;

            // Set Month
            ((Excel.Range)wsheet.Cells[2, 2]).Value2 = engMonths[currMonth.Month - 1];
            // Set year:
            ((Excel.Range)wsheet.Cells[3, 2]).Value2 = currMonth.Year;

            int currentCol = 5;

            foreach (DataGridViewRow row in rows)
            {
                try
                {
                    TimeSpan rowWorkLength = TimeSpan.Parse((string)row.Cells["cTIME"].Value);
                    TimeSpan rowStartTime  = TimeSpan.Parse((string)row.Cells["cStart"].Value);

                    if (rowWorkLength.TotalMinutes > 0)
                    {
                        if (rowWorkLength < minWorkdayLength)
                        {
                            throw new Exception("Not enough hours for this day!");
                        }

                        TimeSpan rowBreakLength = TimeSpan.Zero;
                        if (rowWorkLength > minWorkForBreak)
                        {
                            rowBreakLength = breakLength;
                        }

                        HourTypeRow workType = HourTypeRow.WORK;
                        if (rowWorkLength - rowBreakLength < minWorkForBreak)
                        {
                            // if you work 6.10 but taken 0.5 break you left with 5.4 and not qulify
                            // for break, so we need special code:
                            workType = HourTypeRow.WORK_FORCE_BREAK;
                        }

                        ((Excel.Range)wsheet.Cells[workType, currentCol]).Value
                            = timeStr(rowStartTime);
                        ((Excel.Range)wsheet.Cells[workType, currentCol + 1]).Value
                            = timeStr(rowStartTime + rowWorkLength - rowBreakLength);

                        if (rowBreakLength.TotalMinutes > 0)
                        {
                            ((Excel.Range)wsheet.Cells[HourTypeRow.BREAK, currentCol]).Value
                                = timeStr(rowStartTime + rowWorkLength - rowBreakLength);
                            ((Excel.Range)wsheet.Cells[HourTypeRow.BREAK, currentCol + 1]).Value
                                = timeStr(rowStartTime + rowWorkLength);
                        }
                    }
                    else
                    {
                        // No work hours ! Find reason:
                        DataGridViewComboBoxCell cell =
                            ((DataGridViewComboBoxCell)row.Cells["cOther"]);
                        rowWorkLength = fulldayLength;
                        rowStartTime  = defaultDayStart;

                        if (cell.Value == null)
                        {
                            throw new Exception("No time and no reason!");
                        }
                        else
                        {
                            int reasonIndex = cell.Items.IndexOf(cell.Value);

                            if (reasonIndex == 0)
                            {
                                // Ignore
                            }
                            else
                            {
                                int rowIndex = (int)HourTypeRow.OTHER_START - 1 + reasonIndex;
                                ((Excel.Range)wsheet.Cells[rowIndex, currentCol]).Value     = timeStr(rowStartTime);
                                ((Excel.Range)wsheet.Cells[rowIndex, currentCol + 1]).Value = timeStr(rowStartTime + rowWorkLength);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error on date:" + row.Cells[0].Value.ToString() + Environment.NewLine +
                                    ex.Message + Environment.NewLine + ex.StackTrace
                                    );
                }

                currentCol += 3;
            }

            workbook.SaveAs(exportPath);
            workbook.Close(SaveChanges: false);

            app.Quit();
        }
Пример #27
0
        private void inventoryLoadData(int pageNum)
        {
            int importTotal = 0, exportTotal = 0, itemTotal = 0, netTotal = 0, returnTotal = 0;

            dgvInventory.Rows.Clear();
            DataGridViewRowCollection rows = dgvInventory.Rows;
            InventroyRPTInfo          view = new InventroyRPTInfo(APConfig.Conn);

            view.Conditions = " 1=1 ";
            if (!string.IsNullOrEmpty(txtInventoryName.Text))
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.name.ToString(), txtInventoryName.Text);
            }
            if (!string.IsNullOrEmpty(dpkInventoryINSDTTM.Value.ToString()) && ckbInventoryINDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.importSDTTM.ToString(), dpkInventoryINSDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkInventoryINEDTTM.Value.ToString()) && ckbInventoryINDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.importEDTTM.ToString(), dpkInventoryINEDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkInventoryOUTSDTTM.Value.ToString()) && ckbInventoryOUTDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.exportSDTTM.ToString(), dpkInventoryOUTSDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkInventoryOUTEDTTM.Value.ToString()) && ckbInventoryOUTDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.exportEDTTM.ToString(), dpkInventoryOUTEDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkInventoryRETURNSDTTM.Value.ToString()) && ckbInventoryRETURNDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.returnSDTTM.ToString(), dpkInventoryRETURNSDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkInventoryRETURNEDTTM.Value.ToString()) && ckbInventoryRETURNDTTM.Checked)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.returnEDTTM.ToString(), dpkInventoryRETURNEDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (ddlInventoryVendor.SelectedIndex != 0)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.vendor.ToString(), ddlInventoryVendor.SelectedItem.ToString());
            }
            if (ddlInventoryDealer.SelectedIndex != 0)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.dealer.ToString(), ddlInventoryDealer.SelectedItem.ToString());
            }
            if (ddlInventoryStatus.SelectedIndex != 0)
            {
                view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.status.ToString(), ddlInventoryStatus.SelectedItem.ToString());
            }

            view.condFormat(string.Format(" AND {0} ", view.Conditions));



            //組排序指令
            if (dgvInventory.SortedColumn is null)
            {
                view.OrderBy = view.getOptionOrderBy(RosterDial_RInfo.ncSort.Default.ToString());
            }
            else
            {
                string sortname = dgvInventory.SortedColumn.Name;
                string sortmode = APConfig.GetValueFromDescription <SortMode>(dgvInventory.SortOrder.ToString()).ToString();
                view.OrderBy = string.Format("{0} {1}", view.getOptionOrderBy(sortname), sortmode);
            }
            //查詢頁數初始化且自動跳轉至第一頁
            if (pageNum == 0)
            {
                APConfig.loadPage(ddlInventoryPage, view.calculatePage(APConfig.PageCount));
                return;
            }
            //塞入資料
            DataSet ds = APConfig.GoPage(view.SQLStatement, pageNum);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                rows.Add(new Object[] { dr.ItemArray[4], dr.ItemArray[0], dr.ItemArray[1], dr.ItemArray[2], dr.ItemArray[3], dr.ItemArray[5], dr.ItemArray[6], dr.ItemArray[7], dr.ItemArray[8], dr.ItemArray[9], dr.ItemArray[10], dr.ItemArray[11], dr.ItemArray[12] });
            }
            //計算總合
            if (view.load())
            {
                while (!view.IsEof)
                {
                    importTotal += view.INTOTAL;
                    exportTotal += view.OUTTOTAL;
                    netTotal    += view.NET;
                    returnTotal += view.RETURNTOTAL;
                    itemTotal   += Convert.ToInt32(view.STOCK);
                    view.next();
                }
            }
            lblInventoryTotal.Text     = string.Format("{0}", itemTotal.ToString());
            lblInventoryINAMT.Text     = string.Format("{0:n0} 元", importTotal);
            lblInventoryOUTAMT.Text    = string.Format("{0:n0} 元", exportTotal);
            lblInventoryRETURNAMT.Text = string.Format("{0:n0} 元", returnTotal);
            lblInventoryNETTotal.Text  = string.Format("{0:n0} 元", netTotal);
        }
 public static IEnumerable <T> Select <T>(this DataGridViewRowCollection rows, Func <DataGridViewRow, T> selector)
 {
     return(rows.Cast <DataGridViewRow>().Select(selector));
 }
        /// <summary>
        /// printReport
        /// PDFを出力する
        /// </summary>
        private void printReport()
        {
            //PDF作成後の入れ物
            string strFile = "";

            //データの取り出し用
            DataTable dtPrintData = new DataTable();

            //列情報を取得
            DataGridViewColumnCollection cols = gridTokuteimukesakiTanka.Columns;

            //行情報を取得
            DataGridViewRowCollection rows = gridTokuteimukesakiTanka.Rows;

            //取引先経理情報登録時の情報
            List <string> lstTorihiki = new List <string>();

            foreach (DataGridViewColumn c in cols)
            {
                if (c.ValueType != null)
                {
                    dtPrintData.Columns.Add(c.Name, c.ValueType);
                }
                else
                {
                    dtPrintData.Columns.Add(c.Name);
                }
            }

            foreach (DataGridViewRow r in rows)
            {
                List <object> array = new List <object>();

                foreach (DataGridViewCell cell in r.Cells)
                {
                    array.Add(cell.Value);
                }

                dtPrintData.Rows.Add(array.ToArray());
            }

            //ビジネス層のインスタンス生成
            M1160_TokuteimukesakiTanka_B tokuteimukesakitankaB = new M1160_TokuteimukesakiTanka_B();

            try
            {
                //初期値
                Common.Form.PrintForm pf = new Common.Form.PrintForm(this, "", CommonTeisu.SIZE_A4, YOKO);

                pf.ShowDialog(this);

                //プレビューの場合
                if (this.printFlg == CommonTeisu.ACTION_PREVIEW)
                {
                    this.Cursor = Cursors.WaitCursor;

                    //現在時間と使用者PCユーザー名を確保
                    lstTorihiki.Add(DateTime.Now.ToString());
                    lstTorihiki.Add(SystemInformation.UserName);

                    //結果セットをレコードセットに
                    strFile = tokuteimukesakitankaB.dbToPdf(dtPrintData, lstTorihiki);

                    this.Cursor = Cursors.Default;

                    //印刷できなかった場合
                    if (strFile == "")
                    {
                        //印刷時エラーメッセージ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this, "印刷", "印刷時エラーです。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                        basemessagebox.ShowDialog();

                        return;
                    }

                    // プレビュー
                    pf.execPreview(strFile);
                }
                // 一括印刷の場合
                else if (this.printFlg == CommonTeisu.ACTION_PRINT)
                {
                    this.Cursor = Cursors.WaitCursor;

                    //現在時間と使用者PCユーザー名を確保
                    lstTorihiki.Add(DateTime.Now.ToString());
                    lstTorihiki.Add(SystemInformation.UserName);

                    //結果セットをレコードセットに
                    strFile = tokuteimukesakitankaB.dbToPdf(dtPrintData, lstTorihiki);

                    this.Cursor = Cursors.Default;

                    //印刷できなかった場合
                    if (strFile == "")
                    {
                        //印刷時エラーメッセージ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this, "印刷", "印刷時エラーです。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                        basemessagebox.ShowDialog();

                        return;
                    }

                    // 一括印刷
                    pf.execPrint(null, strFile, CommonTeisu.SIZE_A4, CommonTeisu.YOKO, true);
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;

                //エラーロギング
                new CommonException(ex);
                //例外発生メッセージ(OK)
                BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                basemessagebox.ShowDialog();
                return;
            }
        }
        public void ScenariosView_GenerateCalculations_ChangesCorrectlyObservedAndSynced()
        {
            // Setup
            var mocks           = new MockRepository();
            var messageProvider = mocks.Stub <IImporterMessageProvider>();

            mocks.ReplayAll();

            using (var form = new Form())
            {
                var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
                DataImportHelper.ImportReferenceLine(assessmentSection);
                StabilityPointStructuresFailureMechanism failureMechanism = assessmentSection.StabilityPointStructures;
                DataImportHelper.ImportFailureMechanismSections(assessmentSection, failureMechanism);

                CalculationGroup calculationsGroup = assessmentSection.StabilityPointStructures.CalculationsGroup;
                var view = new StabilityPointStructuresScenariosView(calculationsGroup, assessmentSection.StabilityPointStructures);

                form.Controls.Add(view);
                form.Show();

                var structuresImporter = new StabilityPointStructuresImporter(assessmentSection.StabilityPointStructures.StabilityPointStructures,
                                                                              assessmentSection.ReferenceLine, filePath, messageProvider,
                                                                              new StabilityPointStructureReplaceDataStrategy(failureMechanism));
                structuresImporter.Import();

                var listBox      = (ListBox) new ControlTester("listBox").TheObject;
                var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;

                listBox.SelectedItem = failureMechanism.Sections.ElementAt(50);

                // Precondition
                DataGridViewRowCollection rows = dataGridView.Rows;
                CollectionAssert.IsEmpty(rows);

                // Call
                foreach (StabilityPointStructure structure in assessmentSection.StabilityPointStructures.StabilityPointStructures)
                {
                    calculationsGroup.Children.Add(new StructuresCalculationScenario <StabilityPointStructuresInput>
                    {
                        Name            = NamingHelper.GetUniqueName(((CalculationGroup)view.Data).Children, structure.Name, c => c.Name),
                        InputParameters =
                        {
                            Structure = structure
                        }
                    });
                }

                calculationsGroup.NotifyObservers();

                // Assert
                Assert.AreEqual(1, rows.Count);

                DataGridViewCellCollection cells = rows[0].Cells;
                Assert.AreEqual(4, cells.Count);
                Assert.IsTrue(Convert.ToBoolean(cells[isRelevantColumnIndex].FormattedValue));
                Assert.AreEqual(new RoundedDouble(2, 100).ToString(), cells[contributionColumnIndex].FormattedValue);
                Assert.AreEqual("Eerste kunstwerk punt 6-3", cells[nameColumnIndex].FormattedValue);
                Assert.AreEqual("-", cells[failureProbabilityColumnIndex].FormattedValue);
            }

            mocks.VerifyAll();
        }