protected void submit_Click(object sender, EventArgs e)
    {
        Auth auth = new Auth();
        SQLDB db = new SQLDB();

        string netname_user = "";
        string user = User.Identity.Name.ToUpper();
        if (user.Contains("\\"))
            netname_user = user.Substring(user.IndexOf('\\') + 1, user.Length - user.IndexOf('\\') - 1);
        if (db.isAccessAllowed(netname_user))
        {
            string netname = Netname.Text.ToUpper();
            string login = Login.Text.ToUpper();
            string password = Password.Text;
            if (netname.Length < 3)
            {
                MessageBox.Show("Сотрудник не найден!");
                return;
            }
            Employee employee = auth.Authentication(netname, login, password);
            if (employee != null)
                Response.Redirect("Default.aspx?netname=" + employee.Netname);
            else
                MessageBox.Show("Сотрудник не найден!");
        }
        else
        {
            MessageBox.Show("У вас недостаточно прав доступа для входа!");
        }
    }
Example #2
0
 //查詢標準型態資料
 protected void lnkbtn_calStandard_Click(object sender, EventArgs e)
 {
     string vd = ddlst_Device.SelectedValue;
     SQLDB _operator = new SQLDB("VD_STANDARD", "KPT");
     DataSet vdStandard = _operator.Select("Vdid = '" + vd + "' AND Vsrdir = '" + ddlst_Vsrdir.SelectedValue + "'", "Vdid , TypeName,Week,Hours", "VD_STANDARD");
     RunChart(vdStandard);
 }
Example #3
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        SQLDB db = new SQLDB();
        string deviceKind = gv.Rows[e.RowIndex].Cells[1].Text;
        TextBox checkcycle;
        checkcycle = (TextBox)gv.Rows[e.RowIndex].Cells[2].Controls[0];

        if (!IsNumeric(checkcycle.Text))
        {
            ShowMsg2(UpdatePanel1, "請輸入數字");
            return;
        }

        //檢查更新是否成功
        string updatestring = "Update  CD_CheckCycle set cycle= '" + checkcycle.Text + "'  where Devicekind = '" + deviceKind + "'";
        if (db.ExecuteStatement(updatestring))
        {
            ShowMsg2(UpdatePanel1, "更新成功");
        }
        else
        {
            ShowMsg2(UpdatePanel1, "更新失敗");
        }

        gv.EditIndex = -1;
        InitData();
        SearchData();
    }
Example #4
0
 protected override void InitData()
 {
     //BindDropDownListData(ddl_department, (DataSet)Application["App_Systm_Department"], "DepartmentName", "DepartmentID");
     SQLDB db = new SQLDB();
     DataSet ds = db.Select("", "", "role");
     this.gv.DataSource = ds;
     this.gv.DataBind();
 }
Example #5
0
 public bool DelMaterial(string materialid)
 {
     bool suc = false;
     SQLDB _operator = new SQLDB();
     string deletestring = "DELETE ICS_Material where NO= '" + materialid + "'";
     suc = _operator.ExecuteStatement(deletestring);
     return suc;
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        string html = "";
        int month = 0;
        int year = 0;
        int person_id = 0;
        SQLDB sql = new SQLDB();
        Date dt = new Date();
        MonthDB mdb = new MonthDB();

        if (Request.QueryString["month"] != null)
            month = Convert.ToInt32(Request.QueryString["month"]);

        if (Request.QueryString["year"] != null)
            year = Convert.ToInt32(Request.QueryString["year"]);

        if (Request.QueryString["id"] != null)
            person_id = Convert.ToInt32(Request.QueryString["id"]);

        Employee emp = sql.getEmployee(person_id);

        lbEmployeeName.Text = emp.FIO;
        lbPeriodName.Text = mdb.getMonthName(month).ToUpper() + " " + year.ToString();

        string start_period = dt.getDataToSAP(1, month, year);

        List<CheckedHours> hours = sql.getCheckedSchedule(start_period, person_id);

        if (hours.Count > 0)
        {
            html = @"<table cellpadding='0' cellspacing='0' class='main_table' width='270px'>
                            <tr style='background: url(App_Resources/header.bmp) repeat-x;' >
                                <td class='header_table' width='70px' style='border-left: solid 1px #999999; border-top: solid 1px #999999;' >Дата</td>
                                <td class='header_table' width='100px' style='border-top: solid 1px #999999;'>IT</td>
                                <td class='header_table' width='100px' style='border-top: solid 1px #999999;'>SAP</td>
                            </tr>";

            foreach (CheckedHours ch in hours)
            {
                html += "<tr><td width='70px' style='border-left: solid 1px #999999;'>" + ch.DayDate + "</td><td  width='100px'>" + ch.IT_Hours.ToString() + "</td><td  width='100px'>" + ch.SAP_Hours.ToString() + "</td><tr>";
            }

            html += "</table>";
        }
        else
        {
            string msg = "";
            if (dt.isOpen(month, year))
                msg = "Введенный график совпадает с графиком SAP";
            else
                msg = "Нет данных";

            html = "<div class='check_personal' style='width: 270px; height:50px; color: DarkRed;'>" + msg + "</div>";
        }
        lbTable.Text = html;
    }
Example #7
0
 public bool DelProject(string projectno)
 {
     bool suc = false;
     SQLDB _operator = new SQLDB("ICS_Project");
     suc = _operator.Delete("ProjectNO='" + projectno + "'");
     //if (suc)
     //{
     //    Application["App_Mis_Company"] = CommonLib.GetCompany();
     //}
     return suc;
 }
Example #8
0
 protected override void InitData()
 {
     SQLDB _operator = new SQLDB("VD_Info", "KPT");
     string query = "select vdid from VD_Info group by vdid";
     DataSet ds = _operator.SelectQuery(query);
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         ListItem vditem = new ListItem();
         vditem.Value = ds.Tables[0].Rows[i]["vdid"].ToString();
         vditem.Text = ds.Tables[0].Rows[i]["vdid"].ToString();
         ddlst_Device.Items.Add(vditem);
     }
 }
Example #9
0
    protected void SearchData()
    {
        SQLDB db = new SQLDB();
        StringBuilder selectquery = new StringBuilder("select * " +
                             " from View_DeviceConfig v left join ( " +
                             " select Device_ID,MAX(ChecKDate) ChecKDate " +
                             " FROM CD_DeviceCheckDate " +
                            " where checkdate < GETDATE()  " +
                            " group by Device_ID  " +
                            " ) t on v.Device_ID = t.device_ID ");

        string conditionName = ddlst_SearchType.SelectedValue;
        StringBuilder condition = new StringBuilder();
        //若查詢日期則把模糊查詢like改為=
        if (conditionName == "ContractStartDate" || conditionName == "ContractEndDate" || conditionName == "CheckDate")
        {
            if (txt_StartDate.Text.Length > 0 && txt_EndDate.Text.Length > 0)
            {
                condition.Append(conditionName + ">  '" + txt_StartDate.Text + "' AND " + conditionName + "< '" + txt_EndDate.Text + "'");
            }
            else
            {
                if (txt_StartDate.Text.Length > 0)
                {
                    condition.Append(conditionName + "> '" + txt_StartDate.Text + "'");

                }
                if (txt_EndDate.Text.Length > 0)
                {
                    condition.Append(conditionName + "< '" + txt_EndDate.Text + "'");
                }
            }
        }
        else
        {
            condition.Append(txt_Query_Reason.Text.Trim().Length > 0 ? " " + conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%' " : "");
        }
        if (condition.Length > 0)
        {
            selectquery.Append(" WHERE " + condition);
        }
        DataSet ds = db.SelectQuery(selectquery.ToString());
        Session["DS_MIS"] = ds;
        gv.DataSource = ds;
        gv.DataBind();
        if (ds.Tables[0].Rows.Count == 0)
        {
            ShowMsg2(UpdatePanel1, "查詢無資料");
        }

    }
    // процедура обработки ajax вызова - формирование списка сотрудников
    public string GetCallbackResult()
    {
        string argum = eventArgument;

        string date = argum.Substring(0, 10);
        string text = argum.Substring(10);
        DateTime dt = DateTime.Parse(date);

        SQLDB sql = new SQLDB();
        sql.insertNotes(employee_id, text, Convert.ToInt32(user.TabNum), role_id, dt);

        string url = "Bookmark.aspx?eid=" + employee_id.ToString() + "&rid=" + role_id.ToString();

        return url;
    }
 private bool LoadData()
 {
     bool suc = false;
     SQLDB db = new SQLDB("CD_MaterialOfDevice");
     DataSet ds = new DataSet();
     ds = db.Select("Device_ID = '"+hidden_DeviceID.Value+"'","","CD_MaterialOfDevice");
     if (ds.Tables[0].Rows.Count > 0)
     {
         suc = true;
         gv_Material.DataSource = ds;
         gv_Material.DataBind();
         Session["MIS_Material"] = ds;
     }
     return suc;
 }
 protected void SearchData()
 {
     SQLDB _operator = new SQLDB("DeviceKind");
     string conditionName = ddlst_SearchType.SelectedValue;
     string condition = (txt_Query_Reason.Text.Trim().Length > 0 ? " " + conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%' " : "");
     //condition += query_company;
     DataSet ds = _operator.Select(condition);
     Session["DS_MIS"] = ds;
     gv.DataSource = ds;
     gv.DataBind();
     if (ds.Tables[0].Rows.Count == 0)
     {
         ShowMsg2(UpdatePanel1, "查詢無資料");
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null) Response.Redirect("Default.aspx");
        this.user = (Person)Session["User"];
        SQLDB sql = new SQLDB();

        if (Request.QueryString["eid"] != null) employee_id = Convert.ToInt32(Request.QueryString["eid"].ToString());
        if (Request.QueryString["rid"] != null) role_id = Convert.ToInt32(Request.QueryString["rid"]);

        string employee_fio = sql.getFIO(employee_id);
        lbTitle.Text = employee_fio + "&nbsp;&nbsp;" + employee_id;

        string html = "<table class='notes-table'>";

        List<Note> notes = sql.getNotes(employee_id);
        int k = 0;

        foreach (Note note in notes)
        {
            k++;
            string role = "";
            switch (note.RoleID)
            {
                case 1:
                    role = "Табельщик";
                    break;
                case 2:
                    role = "HR";
                    break;
                case 3:
                    role = "Бухгалтер";
                    break;
                default:
                    role = "нет";
                    break;
            }
            html += "<tr><td class='notes-field-num'>" + k.ToString() + "</td><td class='notes-field-fio'><div style='width: 200px; overflow: hidden;'>" + sql.getFIO(Convert.ToInt32(user.TabNum)) + "</div></td><td class='notes-field-date-record'>" + note.DateNote.ToString() + "</td></tr><tr><td class='notes-field-num'>&nbsp;</td><td class='notes-field-fio'>Роль:&nbsp;" + role + "</td><td class='notes-field-date-record'>Срок:&nbsp;" + note.DateExpire.ToString("dd.MM.yyyy") + "</td></tr><tr><td class='notes-field-text' colspan='3'><div>" + note.Text + "</div></td></tr>";
        }

        html += "</table>";

        lbNotes.Text = html;

        string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ClientBookmarkCallback", "context");
        string func_name = "BookmarkCallback";
        string cbScript = "function " + func_name + "(arg, context)" + "{" + cbReference + ";" + "}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), func_name, cbScript, true);
    }
Example #14
0
    protected void File_Upload(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {

        string filename = e.FileName;
        string strDestPath = Server.MapPath("../Temp/");
        //將資料存到網站
        AjaxFileUpload1.SaveAs(@strDestPath + filename);
        //將資料存到DB
        SQLDB _operator = new SQLDB();
        DataSet ds = _operator.Select("1=0", "", "StudyFileUpload");
        DataRow dr = ds.Tables[0].NewRow();
        dr["FileName"] =  filename;
        dr["UpdateTime"] = DateTime.Now;
        ds.Tables[0].Rows.Add(dr);
        DataSet DSChange = ds.GetChanges();
        _operator.Insert(DSChange);
    }
Example #15
0
    protected void SearchData()
    {
        gv.DataSource = null;
        gv.DataBind();

        SQLDB db = new SQLDB();
        StringBuilder query = new StringBuilder(" select * from ");
        query.Append(" (SELECT DeviceID,COUNT(*) as counts ");
        query.Append(" FROM WarrantyNotify ");

        string conditionName = ddlst_SearchType.SelectedValue;
        if (txt_startDateTime.Text.Length > 0 || txt_endDateTime.Text.Length > 0)
        {
            query.Append(" WHERE ");
            if (txt_startDateTime.Text.Length > 0 && txt_endDateTime.Text.Length > 0)
            {
                query.Append(" NotifyDate >= '" + txt_startDateTime.Text + "' and NotifyDate <= '" + txt_endDateTime.Text + "' ");
            }
            else if (txt_startDateTime.Text.Length > 0)
            {
                query.Append(" NotifyDate >= '" + txt_startDateTime.Text + "' ");
            }
            else if (txt_endDateTime.Text.Length > 0)
            {
                query.Append(" NotifyDate <= '" + txt_endDateTime.Text + "'  ");
            }
        }
        query.Append(" GROUP BY  deviceid) w left join View_DeviceConfig d on w.deviceid = d.Device_ID "); 
        if (txt_Query_Reason.Text.Trim().Length > 0)
        {
            query.Append(" where "+conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%' ");
        }
        query.Append("order by counts desc");
        DataSet ds = db.SelectQuery(query.ToString());
        //Session["DS_MIS"] = ds;
        gv.DataSource = ds;
        gv.DataBind();

        if (ds.Tables[0].Rows.Count == 0)
        {
            ShowMsg2(UpdatePanel1, "查詢無資料");
        }


    }
 private void FillCashAcc()
 {
     try
     {
         string strCMD = "SELECT AM_ACCOUNT_ID,AM_ACCOUNT_NAME FROM FA_ACCOUNT_MASTER WHERE AM_ACCOUNT_TYPE_ID='CASH' AND AM_COMPANY_CODE='" + CommonData.CompanyCode + "'";
         objDB = new SQLDB();
         DataTable dt = objDB.ExecuteDataSet(strCMD).Tables[0];
         if (dt.Rows.Count > 0)
         {
             cmbCashAccount.DataSource    = dt;
             cmbCashAccount.ValueMember   = "AM_ACCOUNT_ID";
             cmbCashAccount.DisplayMember = "AM_ACCOUNT_NAME";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void GenerateVoucherId()
        {
            try
            {
                string strCMD = "SELECT ISNULL(MAX(VCO_VOUCHER_ID),0)+1 VoucherId FROM FA_VOUCHER_OTHERS WHERE vco_company_code='" + CommonData.CompanyCode +
                                "' AND VCO_BRANCH_CODE='" + CommonData.BranchCode + "' AND VCO_FIN_YEAR='" + CommonData.FinancialYear + "'";

                objDB = new SQLDB();
                DataTable DT = objDB.ExecuteDataSet(strCMD).Tables[0];
                if (DT != null && DT.Rows.Count > 0)
                {
                    txtVoucherId.Text = DT.Rows[0][0].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private int SaveItemDetails()
        {
            objSQLdb = new SQLDB();
            int    iRec   = 0;
            string strCmd = "";

            try
            {
                string[] strBranCode = cbBranches.SelectedValue.ToString().Split('@');
                if (gvItemDetails.Rows.Count > 0)
                {
                    for (int i = 0; i < gvItemDetails.Rows.Count; i++)
                    {
                        strCmd += "INSERT INTO SERVICES_PRODUCT_PROMOTION_ITEMS(SPPI_COMPANY_CODE " +
                                  ", SPPI_STATE_CODE " +
                                  ", SPPI_BRANCH_CODE " +
                                  ", SPPI_DOC_MONTH " +
                                  ", SPPI_TRN_TYPE " +
                                  ", SPPI_TRN_NUMBER " +
                                  ", SPPI_ITEM_ID " +
                                  ", SPPI_QTY " +
                                  ", SPPI_REMARKS " +
                                  ")VALUES('" + cbCompany.SelectedValue.ToString() +
                                  "','" + strBranCode[1] +
                                  "','" + strBranCode[0] +
                                  "','" + Convert.ToDateTime(dtpTrnDate.Value).ToString("MMMyyyy").ToUpper() +
                                  "','PROD PROMOTION','" + txtTrnNo.Text.ToString() +
                                  "','" + gvItemDetails.Rows[i].Cells["ItemId"].Value.ToString() +
                                  "'," + Convert.ToInt32(gvItemDetails.Rows[i].Cells["Qty"].Value) +
                                  ",'" + gvItemDetails.Rows[i].Cells["ItemRemarks"].Value.ToString() + "' )";
                    }
                }
                if (strCmd.Length > 10)
                {
                    iRec = objSQLdb.ExecuteSaveData(strCmd);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(iRec);
        }
Example #19
0
        public DataSet IndentProductCategoryList_GET()
        {
            objSQLdb = new SQLDB();
            DataSet ds = new DataSet();

            try
            {
                ds = objSQLdb.ExecuteDataSet("IndentProductCategoryList_GET", CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                objSQLdb = null;
            }
            return(ds);
        }
        private void FillVillagesList(string CompCode, string BranCode, string DocMonth, string State, string District, string Mandal)
        {
            objSQLdb = new SQLDB();
            DataTable dt     = new DataTable();
            string    strCmd = "";

            clbVillage.Items.Clear();

            try
            {
                State    = State.TrimEnd(',');
                District = District.TrimEnd(',');
                Mandal   = Mandal.TrimEnd(',');

                if (CompCode.Length > 1 && BranCode.Length > 1 && DocMonth.Length > 1 && State.Length > 1 && District.Length > 1)
                {
                    strCmd = "SELECT DISTINCT CM_VILLAGE Village " +
                             " FROM SALES_INV_HEAD " +
                             " INNER JOIN CUSTOMER_MAS  ON CM_FARMER_ID=SIH_FARMER_ID " +
                             " WHERE SIH_COMPANY_CODE IN (" + CompCode + ") AND SIH_BRANCH_CODE IN(" + BranCode + ") " +
                             " AND SIH_DOCUMENT_MONTH IN(" + DocMonth + ") AND CM_STATE IN (" + State + ") " +
                             " and CM_DISTRICT in(" + District + ") and CM_MANDAL in (" + Mandal + ") ORDER BY CM_VILLAGE ASC";

                    dt = objSQLdb.ExecuteDataSet(strCmd).Tables[0];
                }

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        NewCheckboxListItem oclBox = new NewCheckboxListItem();
                        oclBox.Tag  = item["Village"].ToString();
                        oclBox.Text = item["Village"].ToString();
                        clbVillage.Items.Add(oclBox);
                        oclBox = null;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #21
0
        private void GetMajorCostCenterDetails(string MajorId, string MajorName, string MajorSname)
        {
            objSqlDB = new SQLDB();
            DataTable dtMajorCCDel = new DataTable();

            gvCostCenterDetails.Rows.Clear();

            if (txtMajorCCId.Text != "" || txtMajorCostCenterName.Text != "" || txtMajorCostCenterSName.Text != "")
            {
                try
                {
                    dtMajorCCDel = GetCostCenterDetails(MajorId, MajorName, MajorSname).Tables[0];

                    if (dtMajorCCDel.Rows.Count > 0)
                    {
                        btnDelete.Enabled            = false;
                        flagUpdate                   = true;
                        txtMajorCCId.Text            = dtMajorCCDel.Rows[0]["MajorCostCenterId"].ToString();
                        txtMajorCostCenterName.Text  = dtMajorCCDel.Rows[0]["MajorCostCenterName"].ToString();
                        txtMajorCostCenterSName.Text = dtMajorCCDel.Rows[0]["MajorcostCenterShortName"].ToString();
                        if (dtMajorCCDel.Rows[0]["CostMajorid"].ToString() != "")
                        {
                            FillCostCenterDetails(dtMajorCCDel);
                        }
                    }
                    else
                    {
                        //txtMajorCCId.Text = "";
                        //txtMajorCostCenterName.Text = "";
                        //txtMajorCostCenterSName.Text = "";
                        //gvCostCenterDetails.Rows.Clear();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    objSqlDB = null;
                }
            }
        }
        public DataTable dtCompanyDocumentMonth(string strCompCode)
        {
            objData = new SQLDB();
            DataTable dt = new DataTable();

            try
            {
                dt = objData.ExecuteDataSet("SELECT fin_year+'@'+cast(start_date as varchar)+'@'+ cast(end_date as varchar) AS FinYear, document_month AS DocMonth FROM document_month where company_code='" + strCompCode + "' And Status='R' ORDER BY start_date desc", CommandType.Text).Tables[0];
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                objData = null;
            }
            return(dt);
        }
 public SuccessModel <List <CategoryModel> > GetCategoryListForCustomerList()
 {
     try
     {
         return(new SuccessModel <List <CategoryModel> >()
         {
             Data = SQLDB.ExecuteSprocAccessor <CategoryModel>("GetCategoryListForCustomer").ToList(),
             ErrorMessage = null
         });
     }
     catch (Exception ex)
     {
         return(new SuccessModel <List <CategoryModel> >()
         {
             ErrorMessage = ex.Message,
             Data = null
         });
     }
 }
        private int SaveData()
        {
            int    iRes       = 0;
            string strCMD     = "";
            string strCntrlAc = "";

            if (cmbCntrlAcc.SelectedIndex == 0)
            {
                strCntrlAc = "";
            }
            else
            {
                strCntrlAc = cmbCntrlAcc.SelectedValue.ToString();
            }
            try
            {
                if (flagUpdate == false)
                {
                    strCMD = " INSERT INTO FA_ACCOUNT_MASTER(AM_COMPANY_CODE,AM_ACCOUNT_ID,AM_ACCOUNT_NAME,AM_SHORT_NAME," +                                                                                            //AM_ACCOUNT_GROUP_ID," +
                             "AM_ALIE_ID,AM_ACCOUNT_TYPE_ID,AM_DEFAULT_DEBIT_CREDIT_ID,AM_BUDGET_REQUIRED,AM_BUDGET_LOCK,AM_PL_BS," +                                                                                   //AM_SCHEDULE_ID,AM_SCHEDULE_GROUP_ID,AM_DUMMY_ACCOUNT," +
                             "AM_CREATED_BY,AM_CREATED_DATE,AM_LDGR_PRN_FLAG,AM_COSTCENTRE_FLAG) VALUES('" + CommonData.CompanyCode + "','" + txtAccountSearch.Text + "','" + txtName.Text + "','" + txtShrtName.Text + //"',''
                             "','" + AccountFlag + "','" + strCntrlAc + "','" + DefFlag + "','N','N','" + PLBSFlag +
                                                                                                                                                                                                                        //    "','','',''
                             "','" + CommonData.LogUserId + "',GETDATE(),'" + cmbLedFormat.SelectedValue.ToString() + "','" + cmbCostCentFlag.SelectedValue.ToString() + "')";
                }
                else
                {
                    strCMD = " UPDATE FA_ACCOUNT_MASTER SET AM_COMPANY_CODE='" + CommonData.CompanyCode + "',AM_ACCOUNT_NAME='" + txtName.Text + "',AM_SHORT_NAME='" + txtShrtName.Text + "'," + //AM_ACCOUNT_GROUP_ID=''," +
                             "AM_ALIE_ID='" + AccountFlag + "',AM_DEFAULT_DEBIT_CREDIT_ID='" + DefFlag + "',AM_BUDGET_REQUIRED='N',AM_BUDGET_LOCK='N',AM_PL_BS='" + PLBSFlag +
                                                                                                                                                                                                 //"',AM_SCHEDULE_ID='',AM_SCHEDULE_GROUP_ID='',AM_DUMMY_ACCOUNT=''," +
                             "',AM_LAST_MODIFIED_BY='" + CommonData.LogUserId + "',AM_LAST_MODIFIED_DATE=GETDATE(),AM_LDGR_PRN_FLAG='" + cmbLedFormat.SelectedValue.ToString() + "',AM_COSTCENTRE_FLAG='" + cmbCostCentFlag.SelectedValue.ToString() +
                             "' WHERE AM_ACCOUNT_ID='" + txtAccountSearch.Text + "' AND AM_COMPANY_CODE='" + CommonData.CompanyCode + "' ";
                }

                objDB = new SQLDB();
                iRes  = objDB.ExecuteSaveData(strCMD);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(iRes);
        }
    protected void SearchData()
    {
        gv.DataSource = null;
        gv.DataBind();

        SQLDB db = new SQLDB();
        StringBuilder query = new StringBuilder("  SELECT WarrantyCompany,CONVERT(float, AVG(datediff(MINUTE,NotifyDate,RepairDate)))/1440 as avgtime  FROM WarrantyNotify  ");
        query.Append(" where NotifyDate is not null and RepairDate is not null and datediff(MINUTE,NotifyDate,RepairDate)> 0 ");
        string conditionName = ddlst_SearchType.SelectedValue;
        StringBuilder condition = new StringBuilder();
        bool isquery = false;
        if (txt_Query_Reason.Text.Trim().Length > 0)
        {
            condition.Append( conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%' and");
            isquery = true;
        }
        if (txt_startDateTime.Text.Length > 0)
        {
            condition.Append(" NotifyDate >= '" + txt_startDateTime.Text + "' and");
            isquery = true;
        }
        if (txt_endDateTime.Text.Length > 0)
        {
            condition.Append(" NotifyDate <= '" + txt_endDateTime.Text + "'  and");
            isquery = true;
        }
        if (isquery)
        {
            query.Append(" and "+ condition.ToString().Substring(0, condition.ToString().Length - 3));
        }
        query.Append("   GROUP BY  WarrantyCompany   order by avgtime desc");
        DataSet ds = db.SelectQuery(query.ToString());
        //Session["DS_MIS"] = ds;
        gv.DataSource = ds;
        gv.DataBind();

        if (ds.Tables[0].Rows.Count == 0)
        {
            ShowMsg2(UpdatePanel1, "查詢無資料");
        }


    }
Example #26
0
 public Task <int> CreateDB(SQLDB sql)
 {
     return(sql.ExecuteNonQuery(
                "CREATE TABLE IF NOT EXISTS \"Example2\" (" +
                "\"ID\" UUID NOT NULL, " +
                "\"ID2\" UUID NOT NULL, " +
                "\"ID3\" UUID NOT NULL, " +
                "\"ID4\" UUID NOT NULL, " +
                "\"Data1\" BOOLEAN NOT NULL, " +
                "\"Data2\" BOOLEAN, " +
                "\"Data3\" BYTEA NOT NULL, " +
                "\"Data4\" BYTEA, " +
                "\"Data5\" CHAR(1) NOT NULL, " +
                "\"Data6\" CHAR(1), " +
                "\"Data7\" SMALLINT NOT NULL, " +
                "\"Data8\" SMALLINT, " +
                "\"Data9\" INTEGER NOT NULL, " +
                "\"Data10\" INTEGER, " +
                "\"Data11\" BIGINT NOT NULL, " +
                "\"Data12\" BIGINT, " +
                "\"Data13\" BIGINT NOT NULL, " +
                "\"Data14\" BIGINT, " +
                "\"Data15\" FLOAT4 NOT NULL, " +
                "\"Data16\" FLOAT4, " +
                "\"Data17\" FLOAT8 NOT NULL, " +
                "\"Data18\" FLOAT8, " +
                "\"Data19\" NUMERIC NOT NULL, " +
                "\"Data20\" NUMERIC, " +
                "\"Data21\" TEXT NOT NULL, " +
                "\"Data22\" TEXT, " +
                "\"Data23\" BYTEA NOT NULL, " +
                "\"Data24\" BYTEA, " +
                "\"Data25\" UUID NOT NULL, " +
                "\"Data26\" UUID, " +
                "\"Data27\" TIMESTAMP NOT NULL, " +
                "\"Data28\" TIMESTAMP, " +
                "\"Data29\" BIGINT NOT NULL, " +
                "\"Data30\" BIGINT, " +
                "PRIMARY KEY(\"ID\", \"ID2\", \"ID3\", \"ID4\"), " +
                "UNIQUE(\"Data25\"), " +
                "CHECK(\"Data27\" > '1990-05-20') " +
                ");"));
 }
        public DataSet GetDlStates_Proc()
        {
            DataSet ds = new DataSet();

            objSQLdb = new SQLDB();
            try
            {
                ds = objSQLdb.ExecuteDataSet("GetDlStates_Proc", CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                objSQLdb = null;
            }
            return(ds);
        }
 private void FillCompanyDdl()
 {
     objDB = new SQLDB();
     try
     {
         DataTable dtCpy = objDB.ExecuteDataSet("SELECT CM_Company_Code, CM_Company_Name FROM Company_Mas WHERE ACTIVE = 'T'" +
                                                " ORDER BY CM_Company_Name", CommandType.Text).Tables[0];
         //objSecurity.GetCompanyDataSet().Tables[0];
         UtilityLibrary.PopulateControl(cbCompany, dtCpy.DefaultView, 1, 0, "--PLEASE SELECT--", 0);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         objDB = null;
     }
 }
        private void AddAccountDetails_Load(object sender, EventArgs e)
        {
            objDB        = new SQLDB();
            txtSiNo.Text = (((ReceiptVoucher)objRecieptVoucher).gvBillDetails.Rows.Count + 1).ToString();
            DataTable dtAccMas;

            //if (((ReceiptVoucher)objRecieptVoucher).cbEmpType.SelectedIndex == 1)
            //{
            //    //lblMajorCost.Visible = false;
            //    //cmbMajorCost.Visible = false;
            //    dtAccMas = objDB.ExecuteDataSet(" SELECT AM_ACCOUNT_ID,AM_ACCOUNT_NAME AccName FROM FA_ACCOUNT_MASTER  WHERE AM_COMPANY_CODE='" + CommonData.CompanyCode
            //                                            + "' and  AM_ACCOUNT_ID <> '" + ((ReceiptVoucher)objRecieptVoucher).cmbCashAccount.SelectedValue
            //                                            + "' AND AM_COSTCENTRE_FLAG IS NULL and AM_ACCOUNT_GROUP_ID IS NULL ").Tables[0];
            //}
            //else
            //{
            //    //lblMajorCost.Visible = true;
            //    //cmbMajorCost.Visible = true;
            dtAccMas = objDB.ExecuteDataSet(" SELECT AM_ACCOUNT_ID,AM_ACCOUNT_NAME AccName FROM FA_ACCOUNT_MASTER  WHERE AM_COMPANY_CODE='" + CommonData.CompanyCode + "' AND AM_COSTCENTRE_FLAG='Y' and AM_ACCOUNT_GROUP_ID IS NULL ").Tables[0];

            //}

            UtilityLibrary.AutoCompleteComboBox(cmbAccounts, dtAccMas, "AM_ACCOUNT_ID", "AccName");
            if (dtAccMas.Rows.Count > 0)
            {
                DataRow dr = dtAccMas.NewRow();


                cmbAccounts.DataSource    = dtAccMas;
                cmbAccounts.DisplayMember = "AccName";
                cmbAccounts.ValueMember   = "AM_ACCOUNT_ID";
            }
            if (drs != null)
            {
                txtSiNo.Text = drs[0]["SL_NO"].ToString();
                cmbAccounts.SelectedValue = drs[0]["ACC_ID"].ToString();
                //cmbMajorCost.SelectedValue = drs[0]["MAJCOST_ID"].ToString();
                //cbPaymentMode.SelectedItem = drs[0]["PAYMENT_MODE"].ToString();
                //txtChqDDNo.Text = drs[0]["CHQ_DD_NO"].ToString();
                txtReceivedAmt.Text = drs[0]["AMOUNT"].ToString();
                //txtRemarks.Text = drs[0]["REMARKS"].ToString();
            }
        }
Example #30
0
        public DataSet GetDocuments()
        {
            DataSet ds = new DataSet();

            objData = new SQLDB();
            try
            {
                ds = objData.ExecuteDataSet("GetDocumentsHeads", CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                objData = null;
            }
            return(ds);
        }
        private void EcodeSearch()
        {
            objData = new InvoiceDB();
            DataSet dsEmp = new DataSet();

            objSQLDB = new SQLDB();
            try
            {
                Cursor.Current     = Cursors.WaitCursor;
                cbEcode.DataSource = null;
                cbEcode.Items.Clear();
                dsEmp = objSQLDB.ExecuteDataSet("select * from (SELECT ECODE, cast(ECODE as varchar)+'-'+MEMBER_NAME ENAME, company_code Company " +
                                                "FROM EORA_MASTER) Ecodes WHERE upper(ENAME) like upper('%" + txtEcodeSearch.Text.ToString() + "%') Order by ENAME");
                //dsEmp = objData.InvLevelAllEcodeSearch_Get(CommonData.CompanyCode, CommonData.BranchCode, CommonData.DocMonth, txtEcodeSearch.Text.ToString());
                DataTable dtEmp = dsEmp.Tables[0];
                if (dtEmp.Rows.Count > 0)
                {
                    cbEcode.DataSource    = dtEmp;
                    cbEcode.DisplayMember = "ENAME";
                    cbEcode.ValueMember   = "ECODE";
                    FillProductsDataToGrid();
                }
                else
                {
                    strECode = "";
                    gvProductDetails.Rows.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (cbEcode.SelectedIndex > -1)
                {
                    cbEcode.SelectedIndex = 0;
                    strECode = ((System.Data.DataRowView)(cbEcode.SelectedItem)).Row.ItemArray[0].ToString();
                }
                objData        = null;
                Cursor.Current = Cursors.Default;
            }
        }
Example #32
0
        private bool CheckEmployeeIsOnDuty()
        {
            objSQLData = new SQLDB();
            DataTable dt   = new DataTable();
            bool      flag = true;

            try
            {
                string strCmd = "SELECT HEOT_EORA_CODE,HEOT_OD_FROM_DATE,HEOT_OD_TO_DATE FROM HR_EMPLOYEE_OD_TRN WHERE HEOT_EORA_CODE=" + txtEcodeSearch.Text + " ";
                dt = objSQLData.ExecuteDataSet(strCmd).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DateTime fromDate = Convert.ToDateTime(dt.Rows[i]["HEOT_OD_FROM_DATE"].ToString());
                        DateTime toDate   = Convert.ToDateTime(dt.Rows[i]["HEOT_OD_TO_DATE"].ToString());

                        if ((dtpPunchMissDate.Value <= fromDate && dtpPunchMissDate.Value >= toDate) || (dtpPunchMissDate.Value >= fromDate && dtpPunchMissDate.Value <= toDate))
                        {
                            flag = false;
                            MessageBox.Show("Employee is OnDuty on these days ", "Punch Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(flag);
                        }
                        //else if ((dtFromDate.Value >= (fromDate) && dtpToDate.Value <= (toDate)) || (dtFromDate.Value >= (fromDate) && dtpToDate.Value <= (fromDate)))
                        //{
                        //    flag = false;
                        //    MessageBox.Show("Employee is on  OnDuty  these days");
                        //    return flag;
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            finally
            {
                objSQLData = null;
                dt         = null;
            }
            return(flag);
        }
Example #33
0
        private void gvEmpPFDetails_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == gvEmpPFDetails.Columns["Edit"].Index)
            {
                txtPfNo.Text     = gvEmpPFDetails.Rows[e.RowIndex].Cells["EmpPFNo"].Value.ToString();
                txtPFBasic.Text  = gvEmpPFDetails.Rows[e.RowIndex].Cells["EmpPFBasic"].Value.ToString();
                dtpEffDate.Value = Convert.ToDateTime(gvEmpPFDetails.Rows[e.RowIndex].Cells["EffDate"].Value);
                txtPfNo.Focus();

                flagUpdate = true;
            }
            if (e.ColumnIndex == gvEmpPFDetails.Columns["Delete"].Index)
            {
                objSQLdb = new SQLDB();
                int iResult = 0;

                DialogResult dlgResult = MessageBox.Show("Do you want Delete this Record?", "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dlgResult == DialogResult.Yes)
                {
                    try
                    {
                        string strDelete = "DELETE FROM PR_PF_DATA WHERE PPD_TRN_ID=" + Convert.ToInt32(TrnNo) + " ";
                        iResult = objSQLdb.ExecuteSaveData(strDelete);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }

                    if (iResult > 0)
                    {
                        flagUpdate = false;
                        GetEmpPfDetails(Convert.ToInt32(txtEcodeSearch.Text));
                        MessageBox.Show("Data Deleted Successfully", "SSERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //btnCancel_Click(null, null);
                    }
                    else
                    {
                        MessageBox.Show("Data Not Deleted", "SSERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Example #34
0
        private int SaveIndentDetlData()
        {
            int           intSave = 0;
            string        strSQL  = string.Empty;
            StringBuilder sbSQL   = new StringBuilder();

            objSQLDB = new SQLDB();
            try
            {
                strSQL = "DELETE from SP_INDENT_DETL" +
                         " WHERE spid_company_code='" + CommonData.CompanyCode +
                         "' AND spid_branch_code='" + CommonData.BranchCode +
                         "' AND spid_indent_number=" + txtIndentNo.Text +
                         "  AND spid_fin_year='" + CommonData.FinancialYear + "'";

                intSave = objSQLDB.ExecuteSaveData(strSQL);

                for (int i = 0; i < gvIndentDetails.Rows.Count; i++)
                {
                    if (gvIndentDetails.Rows[i].Cells["Qty"].Value.ToString() != "" && gvIndentDetails.Rows[i].Cells["Qty"].Value.ToString() != "0")
                    {
                        sbSQL.Append("INSERT INTO SP_INDENT_DETL(spid_company_code, spid_state_code, spid_branch_code, spid_indent_number,spid_fin_year, spid_sl_no, SPID_GROUP, SPID_GLECODE, SPID_STOCK_POINT, SPID_PRODUCT_ID, SPID_REQ_QTY)" +
                                     " VALUES ('" + CommonData.CompanyCode + "', '" + CommonData.StateCode + "', '" + CommonData.BranchCode + "', " + txtIndentNo.Text + ", '" + CommonData.FinancialYear + "'," + gvIndentDetails.Rows[i].Cells["SLNO"].Value +
                                     ", '" + gvIndentDetails.Rows[i].Cells["Group"].Value.ToString().Trim() + "', '" + gvIndentDetails.Rows[i].Cells["GLCode"].Value + "', '" + gvIndentDetails.Rows[i].Cells["BranchCode"].Value +
                                     "', '" + gvIndentDetails.Rows[i].Cells["ProductId"].Value + "', " + gvIndentDetails.Rows[i].Cells["Qty"].Value + "); ");
                    }
                }
                intSave = 0;
                if (sbSQL.ToString().Length > 10)
                {
                    intSave = objSQLDB.ExecuteSaveData(sbSQL.ToString());
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                objSQLDB = null;
            }
            return(intSave);
        }
Example #35
0
    protected void SearchData()
    {
        //string query_company = GetCompanyScope();
        StringBuilder query = new StringBuilder("select * from ICS_Material m left join ICS_Material_Type mt on m.MaterialTypeID = mt.MaterialTypeID left join ICS_Stock_QuantityNow sq on m.NO = sq.MaterialID");
        SQLDB _operator = new SQLDB();
        if (txt_Query_Reason.Text.Trim().Length > 0)
        {
            query.Append(" WHERE  " + ddlst_SearchType.SelectedValue + " like '%" + txt_Query_Reason.Text.Trim() + "%'");
        }
        DataSet ds = _operator.SelectQuery(query.ToString());
        Session["DS_MIS"] = ds;
        gv.DataSource = ds;
        gv.DataBind();
        if (ds.Tables[0].Rows.Count == 0)
        {
            ShowMsg2(UpdatePanel1, "查詢無資料");
        }

    }
        private bool CheckEmployeeIsonLeave()
        {
            objData = new SQLDB();
            DataTable dt   = new DataTable();
            bool      flag = true;

            try
            {
                string strCmd = "SELECT HELT_EORA_CODE,HELT_LEAVE_FROM_DATE,HELT_LEAVE_TO_DATE FROM HR_EMPLOYEE_LEAVE_TRN WHERE HELT_EORA_CODE=" + txtEcodeSearch.Text + "";
                dt = objData.ExecuteDataSet(strCmd).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DateTime fromDate = Convert.ToDateTime(dt.Rows[i]["HELT_LEAVE_FROM_DATE"].ToString());
                        DateTime toDate   = Convert.ToDateTime(dt.Rows[i]["HELT_LEAVE_TO_DATE"].ToString());

                        if ((dtFromDate.Value <= fromDate && dtpToDate.Value >= toDate) || (dtFromDate.Value >= (toDate) && dtpToDate.Value <= (toDate)))
                        {
                            flag = false;
                            MessageBox.Show("Employee applied for Leave on these Dates", "On DutySlip Form", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(flag);
                        }
                        else if ((dtFromDate.Value >= (fromDate) && dtpToDate.Value <= (toDate)) || (dtFromDate.Value >= (fromDate) && dtpToDate.Value <= (fromDate)))
                        {
                            flag = false;
                            MessageBox.Show("Employee applied for Leave on these Dates", "On DutySlip Form", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(flag);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            finally
            {
                objData = null;
                dt      = null;
            }
            return(flag);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckData())
            {
                Int32  imaxApplNo = GetNewApplNo();
                Int32  iAcode     = GetNewACode();
                string sqlText    = "";
                int    iRec       = 0;
                objDB = new SQLDB();
                try
                {
                    sqlText = "INSERT INTO HR_APPL_MASTER_HEAD(HAMH_COMPANY_CODE,HAMH_BRANCH_CODE,HAMH_APPL_NUMBER,HAMH_APPL_DATE,HAMH_RECRUITMENT_SOURCE_CODE,HAMH_RECRUITMENT_SOURCE_DELT_CODE,HAMH_RECRUITMENT_SOURCE_ECODE," +
                              "HAMH_NAME,HAMH_FORH,HAMH_FORH_NAME,HAMH_DOJ,HAMH_DOB,HAMH_NATIVE_PLACE,HAMH_SEX,HAMH_NAIONALITY,HAMH_RELIGION,HAMH_MATRITAL_STATUS,HAMH_EORA_TYPE,HAMH_EORA_CODE,HAMH_CREATED_BY,HAMH_CREATED_DATE," +
                              "HAMH_WORKING_STATUS) VALUES('" + cmbCompany.SelectedValue.ToString() + "','" + cmbBranch.SelectedValue.ToString() + "','" + imaxApplNo + "','" + Convert.ToDateTime(CommonData.CurrentDate).ToString("dd/MMM/yyyy") + "'" +
                              ",'" + cmbSourceCode.SelectedValue.ToString() + "','" + cmbRequtSourDetails.SelectedValue.ToString() + "','" + txtEcodeSearch.Text.ToString() + "','" + txtFullName.Text.ToString() + "'" +
                              ",'" + cmbF_Flg_optional.SelectedItem.ToString() + "','" + txtfName.Text.ToString() + "','" + Convert.ToDateTime(dtpDOJ.Value).ToString("dd/MMM/yyyy") + "','" + Convert.ToDateTime(dtpDOB.Value).ToString("dd/MMM/yyyy") + "'" +
                              ",'" + txtNativePlace_optional.Text + "','" + cmbSex_optional.SelectedItem.ToString() + "','" + cmbNationality.SelectedItem.ToString() + "','" + cmbReligion.SelectedItem.ToString() + "','" + cmbMatrital_optional.SelectedItem.ToString() + "'" +
                              ",'A','" + iAcode + "','" + CommonData.LogUserId + "','" + Convert.ToDateTime(CommonData.CurrentDate).ToString("dd/MMM/yyyy") + "','L'); ";
                    sqlText += "INSERT INTO EORA_MASTER(BRANCH_CODE,DEPT_ID,ECODE,MEMBER_NAME,EORA,HRIS_EMP_NAME,DESG_ID,DESIG,EMP_DOJ,EMP_DOB,FATHER_NAME,elevel_id,company_code,edu_qualification) VALUES('" + cmbBranch.SelectedValue.ToString() + "'" +
                               ",'1200000','" + iAcode + "','" + txtFullName.Text.ToString() + "','A','" + txtFullName.Text.ToString() + "','987','ST','" + Convert.ToDateTime(dtpDOJ.Value).ToString("dd/MMM/yyyy") + "','" + Convert.ToDateTime(dtpDOB.Value).ToString("dd/MMM/yyyy") + "'" +
                               ",'" + txtfName.Text.ToString() + "','95','" + cmbCompany.SelectedValue.ToString() + "','" + cmbTypeEdu.SelectedItem.ToString() + "'); ";
                    iRec = objDB.ExecuteSaveData(sqlText);

                    if (iRec > 0)
                    {
                        MessageBox.Show("Acode Generated For " + txtFullName.Text + "\n ACODE : " + iAcode + "", "SSCRM", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        btnClear_Click(null, null);
                    }
                    else
                    {
                        MessageBox.Show("Data not Saved", "SSCRM", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    objDB = null;
                }
            }
        }
        private void gvAdoptionDetails_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int ires = 0;

            if (e.RowIndex >= 0)
            {
                if (e.ColumnIndex == gvAdoptionDetails.Columns["Delete"].Index)
                {
                    if ((gvAdoptionDetails.Rows[e.RowIndex].Cells["ADPStatus"].Value.ToString() == "Adopted"))
                    {
                        DialogResult dlgResult = MessageBox.Show("Do you want delete this record?", "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dlgResult == DialogResult.Yes)
                        {
                            dgvr = gvAdoptionDetails.Rows[e.RowIndex];

                            objsqldb = new SQLDB();
                            string strcmd = "";
                            try
                            {
                                strcmd = "Delete from SALES_SR_ADOPTIONS Where SSA_EORA_CODE='" + cbEmployees.Text.ToString().Split('-')[0] +
                                         "' and SSA_DOC_MONTH='" + Convert.ToDateTime(dtpDocMonth.Text.ToString()).ToString("MMMyyyy") +
                                         "' and SSA_BRANCH_CODE='" + txtBranch.Tag.ToString() +
                                         "' and SSA_SR_EORA_CODE='" + gvAdoptionDetails.Rows[e.RowIndex].Cells["SREcode"].Value.ToString() + "' ";
                                ires = objsqldb.ExecuteSaveData(strcmd);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                            if (ires > 0)
                            {
                                MessageBox.Show("Data Deleted Successfully", "SRAdoption", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                FillSRAdoptionDetails();
                            }
                            else
                            {
                                MessageBox.Show("Data not Deleted", "SRAdoption", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
            }
        }
Example #39
0
        private void FillBranchData()
        {
            objSQLdb = new SQLDB();
            DataTable dt = new DataTable();

            cbBranches.DataSource = null;
            try
            {
                if (cbCompany.SelectedIndex > 0)
                {
                    string strCommand = "SELECT DISTINCT BRANCH_NAME,BRANCH_CODE+'@'+STATE_CODE as branchCode " +
                                        " FROM USER_BRANCH " +
                                        " INNER JOIN BRANCH_MAS ON BRANCH_CODE = UB_BRANCH_CODE " +
                                        " WHERE COMPANY_CODE ='" + cbCompany.SelectedValue.ToString() +
                                        "' AND UB_USER_ID ='" + CommonData.LogUserId +
                                        "' AND BRANCH_TYPE='BR' ORDER BY BRANCH_NAME ASC";
                    dt = objSQLdb.ExecuteDataSet(strCommand).Tables[0];
                }
                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = "--Select--";
                    dr[1] = "--Select--";

                    dt.Rows.InsertAt(dr, 0);
                    cbBranches.DataSource    = dt;
                    cbBranches.DisplayMember = "BRANCH_NAME";
                    cbBranches.ValueMember   = "branchCode";
                }

                string BranCode = CommonData.BranchCode + '@' + CommonData.StateCode;
                cbBranches.SelectedValue = BranCode;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                objSQLdb = null;
                dt       = null;
            }
        }
Example #40
0
        private void gvEmployeeList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int ires = 0;

            if (e.RowIndex >= 0)
            {
                if (e.ColumnIndex == gvEmployeeList.Columns["Del"].Index)
                {
                    DialogResult dlgResult = MessageBox.Show("Do you want to Delete this Record ", "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dlgResult == DialogResult.Yes)
                    {
                        dgvr  = gvEmployeeList.Rows[e.RowIndex];
                        objDB = new SQLDB();
                        string strcmd = "";

                        try
                        {
                            strcmd = " Delete from HR_EMP_OD_BRANCH_LIST where HOBL_OD_BRANCH_CODE='" + gvEmployeeList.Rows[e.RowIndex].Cells["BRNCODE"].Value +
                                     "' AND HOBL_EORA_CODE='" + txtEcode.Text.ToString() + "' ";

                            strcmd += " EXEC Amsbd_BioTransfer_InsDel_OD " + txtEcode.Text.ToString() +
                                      ",'" + gvEmployeeList.Rows[e.RowIndex].Cells["DvSLNO"].Value + "','DELETE'";

                            objDB = new SQLDB();
                            ires  = objDB.ExecuteSaveData(strcmd);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        if (ires > 0)
                        {
                            MessageBox.Show("Data Deleted Successfully");
                            FillEmpODGridDetails();
                        }
                        else
                        {
                            MessageBox.Show("Data not Deleted");
                        }
                    }
                }
            }
        }
Example #41
0
        private void FillBranchData()
        {
            objSQLdb = new SQLDB();
            DataTable dt = new DataTable();

            cbBranch.DataSource = null;
            try
            {
                if (cbCompany.SelectedIndex > -1 && cbBranchType.SelectedIndex > -1)
                {
                    string strCommand = "SELECT BRANCH_NAME,BRANCH_CODE  FROM BRANCH_MAS " +
                                        " WHERE COMPANY_CODE='" + cbCompany.SelectedValue.ToString() +
                                        "'and BRANCH_TYPE='" + cbBranchType.SelectedValue.ToString() +
                                        "' Order by BRANCH_NAME ";

                    dt = objSQLdb.ExecuteDataSet(strCommand).Tables[0];
                }

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = "--Select--";
                    dr[1] = "--Select--";

                    dt.Rows.InsertAt(dr, 0);

                    cbBranch.DataSource    = dt;
                    cbBranch.DisplayMember = "BRANCH_NAME";
                    cbBranch.ValueMember   = "BRANCH_CODE";
                }

                cbBranch.SelectedValue = CommonData.BranchCode;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                objSQLdb = null;
                dt       = null;
            }
        }
Example #42
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string[]      strArrTask = null;
            StringBuilder sbSQL      = new StringBuilder();
            string        strSQL     = string.Empty;

            try
            {
                if (CheckData())
                {
                    objDA  = new SQLDB();
                    strSQL = "DELETE FROM USER_TASKS WHERE UT_USER_ID='" + ((SSAdmin.NewCheckboxListItem)(clbUsers.SelectedItem)).Tag.ToString() + "'";
                    int del = objDA.ExecuteSaveData(strSQL);

                    TreeNodeCollection nodes = this.treeView1.Nodes;

                    foreach (TreeNode n in nodes)
                    {
                        GetNodeRecursive(n, sbSQL);
                    }

                    strSQL = sbSQL.ToString().Substring(0, sbSQL.ToString().Length - 1);
                    int Rec = objDA.ExecuteSaveData(strSQL);
                    if (Rec > 0)
                    {
                        MessageBox.Show("User Tasks Saved");
                        treeView1.Nodes.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Select atleast one task!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                objDA = null;
            }
        }
Example #43
0
        private void FillDenominationDefDetl()
        {
            string    strSQL = "SELECT * FROM FA_DENM_PMTR WHERE DP_COMPANY_CODE='" + CommonData.CompanyCode + "' order by DP_SORT_NO ";
            SQLDB     objDB  = new SQLDB();
            DataTable dt     = objDB.ExecuteDataSet(strSQL).Tables[0];

            if (dt.Rows.Count > 0)
            {
                gvBillDetails.Rows.Clear();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    gvBillDetails.Rows.Add();
                    gvBillDetails.Rows[i].Cells["SlNo"].Value         = dt.Rows[i]["DP_SORT_NO"];
                    gvBillDetails.Rows[i].Cells["Denomination"].Value = dt.Rows[i]["DP_DENOMIN"];
                    gvBillDetails.Rows[i].Cells["Count"].Value        = "0";
                    gvBillDetails.Rows[i].Cells["AmtReceived"].Value  = "0";
                }
            }
        }
Example #44
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            objSqlDB = new SQLDB();
            DataTable dt         = new DataTable();
            int       iRes       = 0;
            string    strCommand = "";

            if (txtMajorCCId.Text != "" && flagUpdate == true)
            {
                DialogResult dlgResult = MessageBox.Show("Do you want delete this record?", "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dlgResult == DialogResult.Yes)
                {
                    try
                    {
                        strCommand += "DELETE FROM FA_COST_CENTRE WHERE CC_COMPANY_CODE='" + CommonData.CompanyCode +
                                      "' AND CC_MAJOR_COST_CENTRE_ID='" + txtMajorCCId.Text.ToString() + "' ";

                        strCommand += "DELETE FROM FA_MAJOR_COST_CENTRE WHERE MCC_MAJOR_COST_CENTRE_ID='" + txtMajorCCId.Text.ToString() +
                                      "' AND MCC_COMPANY_CODE='" + CommonData.CompanyCode + "' ";

                        if (strCommand.Length > 10)
                        {
                            iRes = objSqlDB.ExecuteSaveData(strCommand);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        objSqlDB = null;
                    }
                    if (iRes > 0)
                    {
                        MessageBox.Show("Data Deleted Successfully", "SSERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        btnClear_Click(null, null);
                        gvCostCenterDetails.Rows.Clear();
                        flagUpdate = false;
                    }
                }
            }
        }
 private void txtEcodeSearch_KeyUp(object sender, KeyEventArgs e)
 {
     if (txtEcodeSearch.Text != "")
     {
         objSQLDB = new SQLDB();
         DataSet ds = objSQLDB.ExecuteDataSet("SELECT * FROM EORA_MASTER WHERE ECODE=" + txtEcodeSearch.Text);
         objSQLDB = null;
         if (ds.Tables[0].Rows.Count > 0)
         {
             txtEName.Text = ds.Tables[0].Rows[0]["MEMBER_NAME"].ToString();
             txtDesig.Text = ds.Tables[0].Rows[0]["DESIG"].ToString();
         }
         else
         {
             txtEName.Text = "";
             txtDesig.Text = "";
         }
     }
 }
Example #46
0
 private bool LoadData()
 {
     txt_MaterialName.Enabled = false;
     SQLDB _operator = new SQLDB("ICS_Material");
     bool suc = false;
     string query = "select * from ICS_Material m left join ICS_Material_Type mt on m.MaterialTypeID = mt.MaterialTypeID where  NO =  '" + hidden_Materialid.Value + "'";
     DataSet ds2 = _operator.SelectQuery(query);
     if (ds2.Tables[0].Rows.Count == 1)
     {
         suc = true;
         DataTable dt = ds2.Tables[0];
         DataRow dr = dt.Rows[0];
         txt_MaterialName.Text = dr["MaterialName"].ToString();
         cbo_materialType.SelectedValue = dr["MaterialTypeID"].ToString();
         txt_MaterialSafeQuantity.Text = dr["MaterialSafeQuantity"].ToString();
         txt_MaterialUnit.Text = dr["MaterialUnit"].ToString();
     }
     return suc;
 }
        public void FillCombiProductsToGrid()
        {
            objSQLdb = new SQLDB();
            DataTable dt     = new DataTable();
            int       intRow = 1;

            gvCombiProductDetails.Rows.Clear();
            try
            {
                string strCommand = "SELECT PM_PRODUCT_ID CombiId " +
                                    ", PM_PRODUCT_NAME CombiName " +
                                    "FROM PRODUCT_MAS " +
                                    "WHERE PM_PRODUCT_TYPE='CMBPK'";
                dt = objSQLdb.ExecuteDataSet(strCommand).Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataGridViewRow  tempRow  = new DataGridViewRow();
                    DataGridViewCell cellSLNO = new DataGridViewTextBoxCell();
                    cellSLNO.Value = intRow;
                    intRow         = intRow + 1;
                    tempRow.Cells.Add(cellSLNO);

                    DataGridViewCell cellCombiId = new DataGridViewTextBoxCell();
                    cellCombiId.Value = dt.Rows[i]["CombiId"];
                    tempRow.Cells.Add(cellCombiId);

                    DataGridViewCell cellCombiName = new DataGridViewTextBoxCell();
                    cellCombiName.Value = dt.Rows[i]["CombiName"];
                    tempRow.Cells.Add(cellCombiName);

                    gvCombiProductDetails.Rows.Add(tempRow);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                objSQLdb = null;
                dt       = null;
            }
        }
        private bool CheckData()
        {
            objDB = new SQLDB();
            if (DateTime.Now.AddDays(-15) < sLastNotice)
            {
                MessageBox.Show("Notice Allready Generated", "Legal :: Notice", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (txtStatus.Text != "LEFT")
            {
                MessageBox.Show("Employee was not left, Notice Generation Restricted to left Employees Only", "Legal :: Notice", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (Convert.ToDouble(txtLoanSanctioned.Text.ToString()) == 0)
            {
                MessageBox.Show("Invalid Loan Amount", "Legal :: Notice", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (txtEngNo.Text.Length == 0 || txtChassisNo.Text.Length == 0)
            {
                MessageBox.Show("Vehicle Engine No / Chassis No not Valid", "Legal :: Notice", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            string sAccess = string.Empty;

            try
            {
                sAccess = objDB.ExecuteDataSet("SELECT UB_STATUS FROM USER_BRANCH WHERE UB_USER_ID='" + CommonData.LogUserId + "' AND UB_BRANCH_CODE='" + sBranchCode + "'").Tables[0].Rows[0][0].ToString();
                if (sAccess.Length == 0)
                {
                    MessageBox.Show("You have no Authorization to generate Legal Notice for this branch employee.", "Legal :: Notice", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            catch
            {
                MessageBox.Show("You have no Authorization to generate Legal Notice for this branch employee.", "Legal :: Notice", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }


            return(true);
        }
Example #49
0
    protected void SearchData()
    {
        gv.DataSource = null;
        gv.DataBind();

        SQLDB db = new SQLDB();
        StringBuilder query = new StringBuilder("  SELECT FaultDescribe,COUNT(*) as counts  FROM WarrantyNotify  ");
        string conditionName = ddlst_SearchType.SelectedValue;
        StringBuilder condition = new StringBuilder();
        bool isquery = false;
        if (txt_Query_Reason.Text.Trim().Length > 0)
        {
            condition.Append(conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%' and");
            isquery = true;
        }
        if (txt_startDateTime.Text.Length > 0)
        {
            condition.Append(" NotifyDate >= '" + txt_startDateTime.Text + "' and");
            isquery = true;
        }
        if (txt_endDateTime.Text.Length > 0)
        {
            condition.Append(" NotifyDate <= '" + txt_endDateTime.Text + "'  and");
            isquery = true;
        }
        if (isquery)
        {
            query.Append(" WHERE " + condition.ToString().Substring(0, condition.ToString().Length - 3));
        }
        query.Append("  GROUP BY  FaultDescribe order by counts desc");
        DataSet ds = db.SelectQuery(query.ToString());
        //Session["DS_MIS"] = ds;
        gv.DataSource = ds;
        gv.DataBind();

        if (ds.Tables[0].Rows.Count == 0)
        {
            ShowMsg2(UpdatePanel1, "查詢無資料");
        }


    }
Example #50
0
    protected void SearchData()
    {
        gv.DataSource = null;
        gv.DataBind();

        SQLDB db = new SQLDB();
        StringBuilder query = new StringBuilder("  select *  ");
        query.Append(" from View_ICS_InventoryCost ");
        string conditionName = ddlst_SearchType.SelectedValue;
        StringBuilder condition = new StringBuilder();
        bool isquery = false;
        if (txt_Query_Reason.Text.Trim().Length > 0)
        {
            condition.Append(conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%' and");
            isquery = true;
        }
        if (txt_startDateTime.Text.Length > 0)
        {
            condition.Append(" si.UpdateTime >= '" + txt_startDateTime.Text + "' and");
            isquery = true;
        }
        if (txt_endDateTime.Text.Length > 0)
        {
            condition.Append(" si.UpdateTime <= '" + txt_endDateTime.Text + "'  and");
            isquery = true;
        }
        if (isquery)
        {
            query.Append(" WHERE " + condition.ToString().Substring(0, condition.ToString().Length - 3));
        }
        DataSet ds = db.SelectQuery(query.ToString());
        //Session["DS_MIS"] = ds;
        gv.DataSource = ds;
        gv.DataBind();

        if (ds.Tables[0].Rows.Count == 0)
        {
            ShowMsg2(UpdatePanel1, "查詢無資料");
        }


    }
Example #51
0
    //修改模式載入資料
    private bool LoadData()
    {
        bool suc = false;

        SQLDB _operator = new SQLDB();
        if (hidden_Caseid.Value != null )
        {
            DataSet ds = new DataSet();
            ds = _operator.Select("caseid = '" + hidden_Caseid.Value + "'", "", "WarrantyNotify");
            if (ds.Tables[0].Rows.Count > 0)
            {
                suc = true;
                DataRow dr = ds.Tables[0].Rows[0];
                DropDownList_DeviceID.SelectedValue = dr["DeviceID"].ToString();
                TextBox_DeviceID_add.Text = dr["DeviceID"].ToString();
                //找出保固廠商的廠商編號,因為資料庫只有紀錄廠商名稱
                if (dr["WarrantyCompany"].ToString().Length > 0)
                {
                    DataSet ds_company = (DataSet)Application["App_Mis_Company"];
                    DataRow[] dr_company = ds_company.Tables[0].Select("CompanyName = '" + dr["WarrantyCompany"].ToString() + "'");
                    DropDownList_WarrantyCompany_add.SelectedValue = dr_company[0]["CompanyID"].ToString();
                }
                DropDownList_WarrantyContract_add.SelectedValue = dr["WarrantyContract"].ToString();
                DropDownList_FaultModel_add.SelectedValue = dr["FaultModel"].ToString();
                TextBox_FaultDescribe_add.Text = dr["FaultDescribe"].ToString();
                DropDownList_ContractCombineNum.SelectedValue = dr["ContractCombineNum"].ToString();
                if (dr["NotifyDate"].ToString().Length > 0)
                    TextBox_NotifyDate_add.Text = Convert.ToDateTime(dr["NotifyDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                if (dr["RepairDeadline"].ToString().Length > 0)
                {
                    TextBox_RepairDeadline_add.Text = Convert.ToDateTime(dr["RepairDeadline"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                }
                DropDownList_RepairDateOption_add.SelectedValue = dr["RepairDateOption"].ToString();
                //併案編號
                DropDownList_ContractCombineNum.SelectedValue = dr["ContractCombineNum"].ToString();
                //重複通知說明
                TextBox_RepeatNotify_add.Text = dr["RepeatNotify"].ToString();

            }
        }
        return suc;
    }
Example #52
0
    protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "cmd_delete")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row = gv.Rows[index];
            string filename = row.Cells[0].Text;
            string delete = " delete StudyFileUpload where FileName = '" + filename + "'";
            SQLDB _operator = new SQLDB();
            if (_operator.ExecuteStatement(delete))
            {
                ShowMsg(UpdatePanel1, "刪除成功");
                SearchData();
            }

            try
            {
                string strDestPath = Server.MapPath("../Temp/");

                FileInfo TheFile = new FileInfo(@strDestPath+filename);
                if (TheFile.Exists)
                {
                    File.Delete(@strDestPath + filename);
                }
                else
                {
                    throw new FileNotFoundException();
                }
            }

            catch (FileNotFoundException ex)
            {
                ShowMsg(UpdatePanel1, ex.Message);
            }
            catch (Exception ex)
            {
                ShowMsg(UpdatePanel1, ex.Message);
            }


        }
    }
Example #53
0
    protected void SearchData()
    {
        gv.DataSource = null;
        gv.DataBind();

        SQLDB db = new SQLDB();
        StringBuilder query = new StringBuilder("  select DeviceID,isnull(AVG(ABS(datediff(day,NotifyDate,RepairDate))),0) as RepairAvgDay FROM WarrantyNotify   ");
        string conditionName = ddlst_SearchType.SelectedValue;
        StringBuilder condition = new StringBuilder();
        bool isquery = false;
        if (txt_Query_Reason.Text.Trim().Length > 0)
        {
            condition.Append(conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%' and");
            isquery = true;
        }
        if (txt_startDateTime.Text.Length > 0)
        {
            condition.Append(" NotifyDate >= '" + txt_startDateTime.Text + "' and");
            isquery = true;
        }
        if (txt_endDateTime.Text.Length > 0)
        {
            condition.Append(" NotifyDate <= '" + txt_endDateTime.Text + "'  and");
            isquery = true;
        }
        if (isquery)
        {
            query.Append(" WHERE " + condition.ToString().Substring(0, condition.ToString().Length - 3));
        }
        query.Append(" group by DeviceID  order by RepairAvgDay desc");
        DataSet ds = db.SelectQuery(query.ToString());
        gv.DataSource = ds;
        gv.DataBind();

        if (ds.Tables[0].Rows.Count == 0)
        {
            ShowMsg2(UpdatePanel1, "查詢無資料");
        }


    }
Example #54
0
    protected void SearchData()
    {
        SQLDB _operator = new SQLDB("VD_DOORSILL", "KPT");
        string conditionName = ddlst_SearchType.SelectedValue;
        string condition = (txt_Query_Reason.Text.Trim().Length > 0 ? " " + conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%' " : "");
        //condition += query_company;
        DataSet ds = _operator.Select(condition);

        ////LINQ 測試
        //DataSet ds_std = _operator.Select("", "", "VD_DOORSILL");
        //DataTable dt = ds_std.Tables[0];
        //var std = (
        //    from std_table in dt.AsEnumerable()
        //    where std_table.Field<string>("DeviceID").ToString().Equals("V012441")
        //    select std_table);

        //std.Single().SetField("DeviceID", "test");

        //if (std.Any())
        //{
        //    DataTable dt_door = std.CopyToDataTable();
        //    gv.DataSource = dt_door;
        //    gv.DataBind();
        //}
        //else
        //{
        //    ShowMsg2(UpdatePanel1, "查詢無資料");
        //}

        Session["DS_MIS"] = ds;
        if (ds.Tables[0].Rows.Count > 0)
        {
            gv.DataSource = ds;
            gv.DataBind();
        }
        else
        {
            ShowMsg2(UpdatePanel1, "查詢無資料");
        }

    }
 protected void submit_Click(object sender, EventArgs e)
 {
     Auth auth = new Auth();
     SQLDB db = new SQLDB();
     string netname = Netname.Text.ToUpper();
     string login = Login.Text.ToUpper();
     string password = Password.Text;
     string tab_num = auth.Authentication(netname, login, password);
     if (tab_num != null)
     {
         List<Role> roles = auth.getRoles(tab_num);
         Person pers = new Person(null, login, password, tab_num, auth.getRoles(tab_num));
         Session["User"] = pers;
         if (roles != null)
         {
             db.insertLogon(tab_num, DateTime.Now, Request.UserHostAddress, Request.UserAgent);
             Response.Redirect("TimeTable.aspx?role=" + roles[0].RoleID);
         }
         else MessageBox.Show("Вам не присвоена роль!");
     }
     else MessageBox.Show("Неправильный логин или пароль!");
 }
Example #56
0
    protected void SearchData()
    {
        SQLDB _operator = new SQLDB("VD_ERRORRECORD", "KPT");
        string conditionName = ddlst_SearchType.SelectedValue;
        StringBuilder condition = new StringBuilder();
        if (conditionName.Equals("RecordTime") || conditionName.Equals("UpdateTime"))
        {
            if (txt_StartDate.Text.Length > 0 && txt_EndDate.Text.Length > 0)
            {
                condition.Append(conditionName + ">  '" + txt_StartDate.Text + "' AND " + conditionName + "< '" + txt_EndDate.Text + "' ");
            }
            else
            {
                if (txt_StartDate.Text.Length > 0)
                {
                    condition.Append(conditionName + "> '" + txt_StartDate.Text + "' ");

                }
                else
                {
                    condition.Append(conditionName + "< '" + txt_EndDate.Text + "' ");
                }
            }
        }
        else
        {
            condition.Append(txt_Query_Reason.Text.Trim().Length > 0 ? " " + conditionName + " like '%" + txt_Query_Reason.Text.Trim() + "%'  " : "");
        }
        DataSet ds = _operator.Select(condition.ToString());
        Session["DS_MIS"] = ds;
        gv.DataSource = ds;
        gv.DataBind();
        if (ds.Tables[0].Rows.Count == 0)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert(\"查詢無資料\");", true);
            //ShowMsg2(UpdatePanel1, "查詢無資料");
        }
    }
 protected void Page_Init(object sender, EventArgs e)
 {
     // авторизация Windows
     Auth auth = new Auth();
     SQLDB db = new SQLDB();
     string netname = "";
     string user = User.Identity.Name.ToUpper();
     if (user.Contains("\\"))
         netname = user.Substring(user.IndexOf('\\') + 1, user.Length - user.IndexOf('\\') - 1);
     string tab_num = auth.Authentication(netname, "", "");
     //string tab_num = auth.Authentication(user, "", "");
     if (tab_num != null)
     {
         List<Role> roles = auth.getRoles(tab_num);
         Person pers = new Person(user, null, null, tab_num, roles);
         Session["User"] = pers;
         if (roles != null)
         {
             db.insertLogon(tab_num, DateTime.Now, Request.UserHostAddress, Request.UserAgent);
             Response.Redirect("TimeTable.aspx?role=" + roles[0].RoleID);
         }
         else MessageBox.Show("Вам не присвоена роль! ");
     }
 }
Example #58
0
    //private void ExportTOExcel()
    //{

    //    ExcelReport report = null;
    //    try
    //    {
    //        report = new ExcelReport("MIS/EquipmentData");

    //        DataSet ds = (DataSet)Session["DS_MIS"];

    //        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
    //        {
    //            report.FillData(j + 3, 1, ds.Tables[0].Rows[j]["DeviceID"].ToString(), 1);
    //            report.FillData(j + 3, 2, ds.Tables[0].Rows[j]["DeviceModelName"].ToString(), 1);
    //            report.FillData(j + 3, 3, ds.Tables[0].Rows[j]["RegionName"].ToString(), 1);
    //            report.FillData(j + 3, 4, ds.Tables[0].Rows[j]["SectorName"].ToString(), 1);
    //            report.FillData(j + 3, 5, ds.Tables[0].Rows[j]["TCModel"].ToString(), 1);
    //            report.FillData(j + 3, 6, ds.Tables[0].Rows[j]["ContractName"].ToString(), 1);
    //            report.FillData(j + 3, 7, ds.Tables[0].Rows[j]["DeviceStatus"].ToString(), 1);
    //            report.FillData(j + 3, 8, ds.Tables[0].Rows[j]["DeviceNote"].ToString(), 1);
    //            report.FillData(j + 3, 9, ds.Tables[0].Rows[j]["Longitude"].ToString(), 1);
    //            report.FillData(j + 3, 10, ds.Tables[0].Rows[j]["Latitude"].ToString(), 1);
    //            //report.FillData(j + 1, 2, ds.Tables[0].Rows[j]["DevicePhoto"].ToString(), 1);
    //        }


    //        ScriptManager.RegisterStartupScript(this, this.GetType(), "newprintwindow2", "open_new_window(\"../Temp/" + report.Report() + "\");", true);
    //    }
    //    catch (Exception e)
    //    {
    //        if (report != null)
    //        {
    //            ScriptManager.RegisterStartupScript(this, this.GetType(), "newprintwindow2", "open_new_window(\"../Temp/" + report.Report() + "\");", true);
    //        }

    //    }
    //    finally
    //    {
    //        try
    //        {
    //            report.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //        }
    //    }

    //}


    /// <summary>
    /// 重新計算檢修周期:以設備合約起始日期開始累加檢修週期直到合約截止
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkbtn_Add_Click(object sender, EventArgs e)
    {
        SQLDB db = new SQLDB();
        //先將舊有檢修日期刪除
        string deleteCheckDate = "Delete from CD_DeviceCheckDate where 1=1";
        db.ExecuteStatement(deleteCheckDate);
        
        string queryDevice = "SELECT [Device_ID],[ContractStartDate],[ContractEndDate],[Cycle] FROM [View_DeviceConfig] where [ContractStartDate] is not null and [ContractEndDate] is not null";
        DataSet ds = db.SelectQuery(queryDevice);
        DataSet ds_checkdate = db.Select("1 = 0", "", "CD_DeviceCheckDate");
        for (int i = 0; i < ds.Tables[0].Rows.Count ; i++)
        {
            string device = ds.Tables[0].Rows[i]["Device_ID"].ToString();
            DateTime start = Convert.ToDateTime(ds.Tables[0].Rows[i]["ContractStartDate"].ToString());
            DateTime end = Convert.ToDateTime(ds.Tables[0].Rows[i]["ContractEndDate"].ToString());
            TimeSpan cycle = TimeSpan.FromDays( Convert.ToDouble( ds.Tables[0].Rows[i]["cycle"].ToString()));
            while (start < end)
            {
                start += cycle;
                if (start < end)
                {
                    DataRow dr = ds_checkdate.Tables[0].NewRow();
                    dr["Device_ID"] = ds.Tables[0].Rows[i]["Device_ID"].ToString();
                    dr["CheckDate"] = start.ToString("yyyy/MM/dd HH:mm:ss");
                    ds_checkdate.Tables[0].Rows.Add(dr);
                }
            }
            
        }

        //開始將檢修日期塞到資料庫
        DataSet DSChange = ds_checkdate.GetChanges();
        if (db.Insert(DSChange))
        {
            ShowMsg(UpdatePanel1, "資料計算成功");
        }
    }
Example #59
0
    protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        SQLDB db = new SQLDB();
        if (e.CommandName == "singleMapView")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row = gv.Rows[index];
            string id = row.Cells[2].Text;
            Response.Redirect("mapViewer.aspx?type=Device&id=" + id);
        }

        if (e.CommandName == "Search")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            DataSet DS = db.Select("device_id = '" + gv.Rows[index].Cells[2].Text.Replace("&nbsp;", "") + "'", " CheckDate desc", "CD_DeviceCheckDate");
            //hid_deviceid.Value = gv2.Rows[index].Cells[0].Text.Replace("&nbsp;", "");
            if (DS.Tables[0].Rows.Count > 0)
            {
                Session["MIS_DeviceHeckDate"] = DS;
                gv3.DataSource = DS;
                gv3.DataBind();
            }
            else
            {
                gv3.DataSource = null;
                gv3.DataBind();
                ShowMsg2(UpdatePanel2, "無資料");
            }
        }
    }
Example #60
0
    protected void lnkbtn_saveStandardall_Click(object sender, EventArgs e)
    {
        SQLDB _operator = new SQLDB("VD_Info", "KPT");
        string query = "select vdid from VD_Info group by vdid";
        DataSet ds_allvd = _operator.SelectQuery(query);
        for (int f = 10; f < ds_allvd.Tables[0].Rows.Count; f++)
        {
            int vsrdir2 = 2;
            for (int k = 0; k < vsrdir2; k++)
            {
                DataSet dsCaledStd = new DataSet();
                dsCaledStd = calStandard(ds_allvd.Tables[0].Rows[f]["vdid"].ToString(), k.ToString(), new DateTime(2014, 06, 09, 12, 0, 0), new DateTime(2014, 07, 09, 12, 0, 0));
                if (dsCaledStd.Tables[0].Rows.Count > 0)
                {
                    DataSet ds_standard = _operator.Select("", "", "VD_STANDARD");
                    DateTime updatetime = DateTime.Now;
                    DataSet ds_standardAdd = _operator.Select("1=0", "", "VD_STANDARD");
                    DataSet ds_standardAddHis = _operator.Select("1=0", "", "VD_STANDARD_HIS");
                    for (int i = 0; i < dsCaledStd.Tables[0].Rows.Count; i++)
                    {
                        DataRow dr = dsCaledStd.Tables[0].Rows[i];
                        string vdid = dr["vdid"].ToString();
                        string vsrdir = dr["vsrdir"].ToString();
                        string week = dr["week"].ToString();
                        string hours = dr["hours"].ToString();

                        DataRow[] dr_std = ds_standard.Tables[0].Select("Vdid = '" + vdid + "' AND Vsrdir = '" + vsrdir + "' AND Week = '" + week + "' AND Hours = '" + hours + "' ");


                        DataRow dr_add = ds_standardAdd.Tables[0].NewRow();
                        dr_add["Vdid"] = vdid;
                        dr_add["TypeName"] = "Default";
                        dr_add["Vsrdir"] = vsrdir;
                        dr_add["Hours"] = hours;
                        dr_add["Week"] = week;
                        dr_add["SpeedAvg"] = dr["SpeedAvg"].ToString();
                        dr_add["SpeedStandard"] = dr["SpeedStandard"].ToString();
                        dr_add["LaneOccupyAvg"] = dr["LaneOccupyAvg"].ToString();
                        dr_add["LaneOccupyStandard"] = dr["LaneOccupyStandard"].ToString();
                        dr_add["FlowAvg"] = dr["FlowAvg"].ToString();
                        dr_add["FlowStandard"] = dr["FlowStandard"].ToString();
                        dr_add["Times"] = 2;
                        dr_add["UpdateTime"] = updatetime;
                        ds_standardAdd.Tables[0].Rows.Add(dr_add);

                        //將有衝突的標準型態備份到VD_STANDARD_HIS
                        if (dr_std.Length > 0)
                        {
                            DataRow dr_addhis = ds_standardAddHis.Tables[0].NewRow();
                            dr_addhis["StandardNum"] = dr_std[0]["StandardNum"];
                            dr_addhis["Vdid"] = vdid;
                            dr_addhis["TypeName"] = "Default";
                            dr_addhis["Vsrdir"] = vsrdir;
                            dr_addhis["Hours"] = hours;
                            dr_addhis["Week"] = week;
                            dr_addhis["SpeedAvg"] = dr_std[0]["SpeedAvg"].ToString();
                            dr_addhis["SpeedStandard"] = dr_std[0]["SpeedStandard"].ToString();
                            dr_addhis["LaneOccupyAvg"] = dr_std[0]["LaneOccupyAvg"].ToString();
                            dr_addhis["LaneOccupyStandard"] = dr_std[0]["LaneOccupyStandard"].ToString();
                            dr_addhis["FlowAvg"] = dr_std[0]["FlowAvg"].ToString();
                            dr_addhis["FlowStandard"] = dr["FlowStandard"].ToString();
                            dr_addhis["Times"] = 2;
                            dr_addhis["UpdateTime"] = updatetime;
                            ds_standardAddHis.Tables[0].Rows.Add(dr_addhis);

                            dr_std[0].Delete();
                        }
                    }

                    DataSet DSChange = ds_standard.GetChanges(DataRowState.Deleted);
                    if (DSChange != null)
                    {
                        if (_operator.Delete(DSChange))
                        {
                            // ShowMsg(UpdatePanel1, "資料刪除成功");
                        }
                    }

                    DataSet DSChangeAdd = ds_standardAdd.GetChanges();
                    DataSet DSChangeAddHis = ds_standardAddHis.GetChanges();
                    bool suc = false;
                    if (DSChangeAdd != null)
                    {
                        if (_operator.Insert(DSChangeAdd))
                        {
                            suc = true;
                        }
                    }
                    if (DSChangeAddHis != null)
                    {
                        if (_operator.Insert(DSChangeAdd))
                        {
                            suc = true;
                        }
                    }

                    //if (suc)
                    //{
                    //    ShowMsg(UpdatePanel2, "建立成功");
                    //}
                }
            }
        }
        ShowMsg(UpdatePanel2, "建立成功");
    }