IndexOfKey() публичный Метод

public IndexOfKey ( Object key ) : int
key Object
Результат int
Пример #1
0
        public void LoadMoudelTree(string roleCode)
        {
            DataTable tempTable = roleBll.GetUserModuleListByRoleCode(roleCode);
            this.UltraWebTreeModule.Nodes.Clear();
            SortedList allTreeNodes = new SortedList();
            foreach (DataRow row in tempTable.Rows)
            {
                Node newNode = base.CreateNode(Convert.ToString(row["modulecode"]), FunctionText.ResourceManager.GetString(row["LANGUAGE_KEY"].ToString()) + this.CreateFunctionList(Convert.ToString(row["FunctionList"]), Convert.ToString(row["FunctionListed"]), Convert.ToString(row["Authorized"])), Convert.ToString(row["authorized"]).Equals("Y"), Convert.ToDecimal(tempTable.Compute("count(modulecode)", "parentmodulecode='" + row["modulecode"] + "'")) == 0M);
                allTreeNodes.Add(Convert.ToString(row["modulecode"]), newNode);
                if (row["parentmodulecode"].ToString().Trim().Length > 0)
                {
                    if (allTreeNodes.IndexOfKey(row["parentmodulecode"]) >= 0)
                    {
                        ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentmodulecode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["modulecode"])));
                    }
                }
                else
                {
                    this.UltraWebTreeModule.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["modulecode"]))));
                }
                foreach (Node node in this.UltraWebTreeModule.Nodes)
                {
                    node.Expand(true);

                }
            }
        }
Пример #2
0
        public double[,] CalcCachedInterpolationInfo(double a_dTime, SortedList a_sorted)
        {
            double[,] aReturn = new double[,]{{1}};

            int nIndex = 0;
            //			if (a_sorted.ContainsKey(a_dTime))
            nIndex = a_sorted.IndexOfKey(a_dTime);
            if (nIndex >= 0)
            {
                return new double[,]{{(double)a_sorted.GetByIndex(nIndex)}};
            }
            else
            {
                a_sorted.Add(a_dTime, -4711);
                nIndex = a_sorted.IndexOfKey(a_dTime);
                a_sorted.RemoveAt(nIndex);
            }

            //nIndex is meant to represent the next index after a_dTime.
            //If a_dTime is the same as a key, nIndex should be that key's index - 1

            if (nIndex <= 0)
                return new double[,]{{(double)a_sorted.GetByIndex(0)}};

            if (nIndex >= a_sorted.Count)
                return new double[,]{{(double)a_sorted.GetByIndex(a_sorted.Count-1)}};

            double dTimeAtIndexBefore = (double)a_sorted.GetKey(nIndex-1);
            double dTimeAtIndexAfter = (double)a_sorted.GetKey(nIndex);

            if (a_dTime == dTimeAtIndexAfter)
            {
                /*    if (nPos < nCnt) then nPos = nPos+1
            fTimePosBefore = a_paList.getPropAt(nPos-1)
            fTimePosAfter = a_paList.getPropAt(nPos)*/
            }

            double dVal1 = 0;
            double dVal2 = (double)a_sorted.GetValueList()[nIndex-1];
            double dVal3 = (double)a_sorted.GetValueList()[nIndex];
            double dVal4 = 0;
            //TODO: support commands in the list!
            //if (ilk(mvVal2) = #List) then mvVal2 = mvVal3
            //if (ilk(mvVal3) = #List) then mvVal3 = mvVal2

            if (nIndex == 1)
                dVal1 = dVal2;
            else
                dVal1 = (double)a_sorted.GetValueList()[nIndex-2];
            //if (ilk(mvVal1) = #List) then mvVal1 = mvVal2

            if (nIndex == a_sorted.Count-1)
                dVal4 = dVal3;
            else
                dVal4 = (double)a_sorted.GetValueList()[nIndex+1];
            //TODO if (ilk(mvVal4) = #List) then mvVal4 = mvVal3

            aReturn = new double[,] {{dVal1, 0}, {dVal2, dTimeAtIndexBefore}, {dVal3, dTimeAtIndexAfter}, {dVal4,0}};
            return aReturn;
        }
Пример #3
0
        public void Test01()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            SortedList sl2 = null;
            Hashtable ht = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            //
            // Construct a hashtable with 3 elements in an unsorted order
            //
            ht = new Hashtable();
            var k0 = new SortedListCtorTestClass("cde");
            var k1 = new SortedListCtorTestClass("abc");
            var k2 = new SortedListCtorTestClass("bcd");

            ht.Add(k0, null);
            ht.Add(k1, null);
            ht.Add(k2, null);

            //
            // Constructor: Create a SortedList using the hashtable (dictionary) created
            //
            sl2 = new SortedList(ht);

            // Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            // Verify that the SortedList Count is right.
            Assert.Equal(3, sl2.Count);

            // Verify that the SortedList actually sorted the hashtable.
            Assert.Equal(2, sl2.IndexOfKey(k0));

            Assert.Equal(0, sl2.IndexOfKey(k1));

            Assert.Equal(1, sl2.IndexOfKey(k2));

            // Verify that the SortedList contains the right keys.
            Assert.True(((SortedListCtorTestClass)sl2.GetKey(0)).ToString().Equals("abc"));

            Assert.True(((SortedListCtorTestClass)sl2.GetKey(1)).ToString().Equals("bcd"));

            Assert.True(((SortedListCtorTestClass)sl2.GetKey(2)).ToString().Equals("cde"));

            ht = new Hashtable();
            sl2 = new SortedList(ht);
            Assert.Equal(0, sl2.Count);
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strDepName;
            try
            {
                if (!this.Page.IsPostBack)
                {
                    this.ModuleCode.Value = "KQMSYS306";
                    this.UltraWebTreeData.Nodes.Clear();
                    SortedList allTreeNodes = new SortedList();

                    RelationSelectorBll bll = new RelationSelectorBll();
                    DataTable tempTable = bll.GetTypeDataList(CurrentUserInfo.Personcode, "Foxconn", this.ModuleCode.Value, "N");
                    foreach (DataRow row in tempTable.Rows)
                    {
                        strDepName = row["depname"].ToString() + "[" + row["depcode"].ToString() + "]";
                        if (row["costcode"].ToString().Trim().Length > 0)
                        {
                            strDepName = strDepName + "-" + row["costcode"].ToString();
                        }
                        Node node = base.CreateNode(row["depcode"].ToString(), strDepName, false, Convert.ToDecimal(tempTable.Compute("count(depcode)", "parentdepcode='" + row["depcode"].ToString() + "'")) == 0M);
                        if (row["deleted"].ToString().Equals("Y"))
                        {
                            node.Style.BorderColor = Color.DarkGray;
                        }
                        allTreeNodes.Add(row["depcode"].ToString(), node);
                        if (row["parentdepcode"].ToString().Trim().Length > 0)
                        {
                            if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
                            {
                                ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
                            }
                            else
                            {
                                this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
                            }
                        }
                        else
                        {
                            this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //base.WriteMessage(2, (ex.InnerException == null) ? ex.Message : ex.InnerException.Message);
            }
        }
        public void MethodSortedList()
        {
            sl.Add("key", "SortedObject");
            int index = sl.IndexOfKey("key");

            if (!(sl["key"].Equals("SortedObject")))
            {
                Environment.Exit(-1);
            }

            if (!(sl.GetByIndex(index).Equals("SortedObject")))
            {
                Environment.Exit(-1);
            }

            sl["key"] = "NewSortedObject";
            if (!(sl["key"].Equals("NewSortedObject")))
            {
                Environment.Exit(-1);
            }

            if (!(sl.GetByIndex(index).Equals("NewSortedObject")))
            {
                Environment.Exit(-1);
            }
        }
Пример #6
0
        private void tvcWindows_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            mcPage   aPage;
            mcServer aServer = (mcServer)Servers.GetByIndex(Servers.IndexOfKey(e.Node.Tag));

            /*
             * Locate the server instance.
             * aServer will never be null, as if the above fails
             * the client will crash. This should be OK though
             * s we should NOT be trying to select a non-existant window ;)
             */

            /* find our page */
            aPage = aServer.FindPage(e.Node.Text);
            if (aPage == null)
            {
                /*
                 * all this generally means is that they selected, for example,
                 * a "messages" or "channels" node.
                 */
                aPage = aServer.CurrentPage;
            }
            /* now, we should have a page - focus on it */
            aPage.DoFocus();
        }
Пример #7
0
        /// <summary>
        /// 頁面加載--組織樹
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            string strDepName;

            if (!this.Page.IsPostBack)
            {
                this.ModuleCode.Value = Request.QueryString["ModuleCode"].ToString();
                string personCode = CurrentUserInfo.Personcode;
                string companyId = CurrentUserInfo.CompanyId;
                this.UltraWebTreeData.Nodes.Clear();
                SortedList allTreeNodes = new SortedList();
                RelationSelectorBll bll = new RelationSelectorBll();
                DataTable tempTable = bll.GetTypeDataList(personCode, companyId, this.ModuleCode.Value, "N");
                foreach (DataRow row in tempTable.Rows)
                {

                    strDepName = row["depname"].ToString() + "[" + row["depcode"].ToString() + "]";
                    if (row["costcode"].ToString().Trim().Length > 0)
                    {
                        strDepName = strDepName + "-" + row["costcode"].ToString();
                    }
                    Node node = base.CreateNode(row["depcode"].ToString(), strDepName, false, Convert.ToDecimal(tempTable.Compute("count(depcode)", "parentdepcode='" + row["depcode"].ToString() + "'")) == 0M);
                    if (row["deleted"].ToString().Equals("Y"))
                    {
                        node.Style.ForeColor = Color.DarkGray;
                    }
                    allTreeNodes.Add(row["depcode"].ToString(), node);
                    if (row["parentdepcode"].ToString().Trim().Length > 0)
                    {
                        if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
                        {
                            ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
                        }
                        else
                        {
                            this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
                        }
                    }
                    else
                    {
                        this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
                    }
                }
            }
        }
Пример #8
0
 /// <summary>
 /// Retourne le dictionnaire de la section nommée dans line, crée la section si nécessaire
 /// </summary>
 /// <param name="sections">Dictionnaire des sections</param>
 /// <param name="line">Ligne contenant un délimiteur de section</param>
 /// <returns>Le dictionnaire associé à la section</returns>
 protected SortedList DoCreateSection( SortedList sections, string line ) {
   string name = line.Substring( 1, line.Length - 2 ) ;
   int index = sections.IndexOfKey( name ) ;
   if (index == -1) {
     SortedList result = new SortedList() ;
     sections.Add( name, result ) ;
     return result ;
   } else return (SortedList) sections.GetByIndex( index ) ;
 }
Пример #9
0
        protected void CheckBoxAbate_CheckedChanged(object sender, EventArgs e)
        {
            moudelCode = Request.QueryString["modulecode"].ToString();
            this.UltraWebTreeData.Nodes.Clear();
            SortedList allTreeNodes = new SortedList();

            hrmEmpOtherMoveBll.GetDepCodeTable(CurrentUserInfo.Personcode, moudelCode, CurrentUserInfo.CompanyId, "", chkAbate.Checked ? "Y" : "N",logmodel);
              dt = hrmEmpOtherMoveBll.GetAuthorizedTreeDept(CurrentUserInfo.Personcode, CurrentUserInfo.CompanyId, moudelCode);
            string strDepName = "";
            foreach (DataRow row in dt.Rows)
            {
                strDepName = Convert.ToString(row["depname"]) + "[" + Convert.ToString(row["depcode"]) + "]";
                if (Convert.ToString(row["costcode"]).Trim().Length > 0)
                {
                    strDepName = strDepName + "-" + Convert.ToString(row["costcode"]);
                }
                Node node = base.CreateNode(Convert.ToString(row["depcode"]), strDepName, false, Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0M);
                if (Convert.ToString(row["deleted"]).Equals("Y"))
                {
                    node.Style.ForeColor = Color.Red;
                }
                allTreeNodes.Add(Convert.ToString(row["depcode"]), node);
                if (row["parentdepcode"].ToString().Trim().Length > 0)
                {
                    if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
                    {
                        ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
                    }
                    else
                    {
                        this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
                    }
                }
                else
                {
                    this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
                }
            }
            foreach (Node node in this.UltraWebTreeData.Nodes)
            {
                node.Expand(false);
            }
        }
Пример #10
0
 //綁定所有的組織代碼 (包含已失效的)
 protected void chkAbate_CheckedChanged(object sender, EventArgs e)
 {
     string strDepName;
     string personCode = CurrentUserInfo.Personcode;
     string companyId = CurrentUserInfo.CompanyId;
     this.UltraWebTreeData.Nodes.Clear();
     SortedList allTreeNodes = new SortedList();
     DataTable dt = bll.GetTypeDataList(personCode, companyId, moduleCode);
     foreach (DataRow row in dt.Rows)
     {
         strDepName = Convert.ToString(row["depname"]) + "[" + Convert.ToString(row["depcode"]) + "]";
         if (Convert.ToString(row["costcode"]).Trim().Length > 0)
         {
             strDepName = strDepName + "-" + Convert.ToString(row["costcode"]);
         }
         Node node = base.CreateNode(Convert.ToString(row["depcode"]), strDepName, false, Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0M);
         if (Convert.ToString(row["deleted"]).Equals("Y") || Convert.ToString(row["deleted"]).Equals(""))
         {
             node.Style.ForeColor = Color.Red;
         }
         allTreeNodes.Add(Convert.ToString(row["depcode"]), node);
         if (row["parentdepcode"].ToString().Trim().Length > 0)
         {
             if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
             {
                 ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
             }
             else
             {
                 this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
             }
         }
         else
         {
             this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
         }
     }
     foreach (Node node in this.UltraWebTreeData.Nodes)
     {
         node.Expand(false);
     }
 }
Пример #11
0
            public override int IndexOfKey(object key)
            {
                if (key == null)
                {
                    throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
                }

                lock (_root)
                {
                    return(_list.IndexOfKey(key));
                }
            }
            public override int IndexOfKey(Object key)
            {
                if (key == null)
                {
                    throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key"));
                }
                Contract.EndContractBlock();

                lock (_root) {
                    return(_list.IndexOfKey(key));
                }
            }
Пример #13
0
        /// <summary>
        /// WebTree控件綁定數據
        /// </summary>
        protected void WebTreeBind()
        {
            this.UltraWebTreeData.Nodes.Clear();
            SortedList allTreeNodes = new SortedList();
            DataTable tempTable = moduleBll.GetUserModuleTable();
            foreach (DataRow row in tempTable.Rows)
            {
                allTreeNodes.Add(Convert.ToString(row["ModuleCode"]), base.CreateNode(Convert.ToString(row["ModuleCode"]), Convert.ToString(row["description"]), false, Convert.ToDecimal(tempTable.Compute("count(ModuleCode)", "parentmodulecode='" + row["ModuleCode"] + "'")) == 0M));
                if (row["parentmodulecode"].ToString().Trim().Length > 0)
                {
                    if (allTreeNodes.IndexOfKey(row["parentmodulecode"]) >= 0)
                    {
                        ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentmodulecode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["ModuleCode"])));
                    }
                }
                else
                {
                    this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["ModuleCode"]))));
                }

            }
        }
Пример #14
0
            public override int IndexOfKey(Object key)
            {
                if (key == null)
                {
                    throw new ArgumentNullException("key", SR.ArgumentNull_Key);
                }
                Contract.EndContractBlock();

                lock (_root)
                {
                    return(_list.IndexOfKey(key));
                }
            }
Пример #15
0
 /// <summary>
 /// Ajoute la ligne line à la section en forme clé=valeur
 /// </summary>
 /// <param name="section">Dictionnaire de la section</param>
 /// <param name="line">Ligne de l'archive en forme "clé=valeur"</param>
 protected void DoAddLineToSection( SortedList section, string line ) {
   if (section == null) return ;
   int pos = line.IndexOf( '=' ) ;
   if (pos == -1) {
     string trimmed = line.Trim() ;
     if (trimmed != "") section.Add( trimmed, null ) ;
   } else {
     string key = line.Substring( 0, pos ) ;
     string val = line.Substring( pos + 1 ) ;
     int index = section.IndexOfKey( key ) ;
     if (index != -1) section.RemoveAt( index ) ;
     section.Add( key, val ) ;
   }
 }
 static public int IndexOfKey(IntPtr l)
 {
     try {
         System.Collections.SortedList self = (System.Collections.SortedList)checkSelf(l);
         System.Object a1;
         checkType(l, 2, out a1);
         var ret = self.IndexOfKey(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #17
0
        public static string makeCanonicalString(string verb, string resource,
                                                  SortedList headers, string expires)
        {
            StringBuilder buf = new StringBuilder();
            buf.Append(verb);
            buf.Append("\n");

            SortedList interestingHeaders = new SortedList();
            if (headers != null)
            {
                foreach (string key in headers.Keys)
                {
                    string lk = key.ToLower();
                    if (lk.Equals("content-type") ||
                         lk.Equals("content-md5") ||
                         lk.Equals("date") ||
                         lk.StartsWith(AMAZON_HEADER_PREFIX))
                    {
                        interestingHeaders.Add(lk, headers[key]);
                    }
                }
            }
            if (interestingHeaders[ALTERNATIVE_DATE_HEADER] != null)
            {
                interestingHeaders.Add("date", "");
            }

            // if the expires is non-null, use that for the date field.  this
            // trumps the x-amz-date behavior.
            if (expires != null)
            {
                interestingHeaders.Add("date", expires);
            }

            // these headers require that we still put a new line after them,
            // even if they don't exist.
            {
                string[] newlineHeaders = { "content-type", "content-md5" };
                foreach (string header in newlineHeaders)
                {
                    if (interestingHeaders.IndexOfKey(header) == -1)
                    {
                        interestingHeaders.Add(header, "");
                    }
                }
            }

            // Finally, add all the interesting headers (i.e.: all that startwith x-amz- ;-))
            foreach (string key in interestingHeaders.Keys)
            {
                if (key.StartsWith(AMAZON_HEADER_PREFIX))
                {
                    buf.Append(key).Append(":").Append((interestingHeaders[key] as string).Trim());
                }
                else
                {
                    buf.Append(interestingHeaders[key]);
                }
                buf.Append("\n");
            }

            // Do not include the query string parameters
            int queryIndex = resource.IndexOf('?');
            if (queryIndex == -1)
            {
                buf.Append("/" + resource);
            }
            else
            {
                buf.Append("/" + resource.Substring(0, queryIndex));
            }

            Regex aclQueryStringRegEx = new Regex(".*[&?]acl($|=|&).*");
            Regex torrentQueryStringRegEx = new Regex(".*[&?]torrent($|=|&).*");
            Regex loggingQueryStringRegEx = new Regex(".*[&?]logging($|=|&).*");
            if (aclQueryStringRegEx.IsMatch(resource))
            {
                buf.Append("?acl");
            }
            else if (torrentQueryStringRegEx.IsMatch(resource))
            {
                buf.Append("?torrent");
            }
            else if (loggingQueryStringRegEx.IsMatch(resource))
            {
                buf.Append("?logging");
            }

            return buf.ToString();
        }
Пример #18
0
		public void TestIndexOfKey ()
		{
			SortedList sl1 = new SortedList (24);

			for (int i = 0; i <= 50; i++) {
				string s = string.Format ("{0:D2}", i);
				sl1.Add ("kala " + s, i);
			}
			Assert.AreEqual (-1, sl1.IndexOfKey ("kala "), "#A");

			try {
				sl1.IndexOfKey ((string) null);
				Assert.Fail ("#B");
			} catch (ArgumentNullException) {
			}

			try {
				sl1.IndexOfKey (10);
				Assert.Fail ("#C");
			} catch (InvalidOperationException) {
			}

			for (int i = 0; i <= 50; i++) {
				string s = string.Format ("{0:D2}", i);
				Assert.AreEqual (i, sl1.IndexOfKey ("kala " + s), "#D:" + i);
			}
		}
Пример #19
0
 /* record leaving of a function */
 void LeaveFunction(SortedList functions, int functionId)
 {
     int index = functions.IndexOfKey(functionId);
     if(index != -1)
     {
         int newValue = (int)functions.GetByIndex(index) - 1;
         if(newValue <= 0)
         {
             functions.RemoveAt(index);
         }
         else
         {
             functions.SetByIndex(index, newValue);
         }
     }
 }
Пример #20
0
 /* record call to a function */
 void EnterFunction(SortedList functions, int functionId)
 {
     int index = functions.IndexOfKey(functionId);
     if(index == -1)
     {
         functions.Add(functionId, 1);
     }
     else
     {
         /* if in the list, add 1 to its counter (need to keep keys unique) */
         functions.SetByIndex(index, 1 + (int)functions.GetByIndex(index));
     }
 }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!this.CheckData(this.textBoxOTDate.Text.ToString(), Message.overtime_date) ||
                    !this.CheckData(this.textBoxBeginTime.Text, Message.start_time) ||
                    !this.CheckData(this.textBoxEndTime.Text, Message.end_time) ||
                    !this.CheckData(this.textBoxHours.Text, Message.times) ||
                    !this.CheckData(this.textBoxWorkDesc.Text, Message.overtime_desc))
                {
                    return;
                }
                string condition = "";
                string strtemp = "";
                string OTDate = "";
                //Function CommonFun = new Function();
                try
                {
                    OTDate = DateTime.Parse(this.textBoxOTDate.Text.ToString()).ToString("yyyy/MM/dd");
                }
                catch (System.Exception)
                {
                    this.WriteMessage(1, Message.common_message_data_errordate);
                    return;
                }

                WorkNo = this.textBoxEmployeeNo.Text.ToUpper();
                string StrBtime = this.textBoxBeginTime.Text.ToString();
                string StrEtime = this.textBoxEndTime.Text.ToString();
                DateTime dtTempBeginTime = DateTime.Parse(OTDate + " " + StrBtime);
                DateTime dtTempEndTime = DateTime.Parse(OTDate + " " + StrEtime);
                //DateTime dtMidTime = DateTime.Parse(OTDate + " 12:00");

                #region 每天16:30后不讓預報加班,非工作日也不能預報加班  龍華總部周邊 update by xukai 20111014
                string LHZBLimitTime = "";
                string LHZBIsLimitApply = "";
                string workflag = "";
                try
                {
                    LHZBIsLimitApply = System.Configuration.ConfigurationManager.AppSettings["LHZBIsLimitAdvApplyTime"];
                    LHZBLimitTime = System.Configuration.ConfigurationManager.AppSettings["LHZBLimitTime"];
                }
                catch
                {
                    LHZBIsLimitApply = "N";
                    LHZBLimitTime = "";
                }

                if (!string.IsNullOrEmpty(LHZBLimitTime))
                {
                    //每天LHZBLimitTime時間后不能新增、修改加班預報
                    DateTime dtLimit = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + LHZBLimitTime);
                    if (dtLimit < DateTime.Now)
                    {
                        this.WriteMessage(1, Message.kqm_otm_advanceapply + LHZBLimitTime + Message.kqm_otm_advanceapply_error);
                        return;
                    }
                }
                if (LHZBIsLimitApply == "Y")
                {
                    //非工作日不能預報加班
                    workflag = wfaddt.GetEmpWorkFlag(WorkNo, DateTime.Now.ToString("yyyy-MM-dd"));
                    if (workflag == "N")
                    {
                        //this.WriteMessage(1, this.GetResouseValue("kqm.otm.advanceapply.workflag"));
                        return;
                    }
                }
                #endregion

                string OTMAdvanceBeforeDays = wfaddt.GetValue("select nvl(max(paravalue),'2') from GDS_SC_PARAMETER where paraname='OTMAdvanceBeforeDays'");
                string appUserIsIn = wfaddt.GetValue("select nvl(max(workno),'Y') from GDS_ATT_EMPLOYEES where workno='" + CurrentUserInfo.Personcode + "'");

                if (!appUserIsIn.Equals("Y"))//允許申報當前日期以前多少天的加班除去非工作日
                {
                    //OTMAdvanceBeforeDays = Convert.ToString(Convert.ToDouble(OTMAdvanceBeforeDays) + 30);
                    int i = 0;
                    int WorkDays = 0;
                    string UserOTType = "";
                    while (i < Convert.ToDouble(OTMAdvanceBeforeDays))
                    {
                        condition = "SELECT workflag FROM GDS_ATT_BGCALENDAR WHERE workday = to_date('" + System.DateTime.Now.AddDays(-1 - i - WorkDays).ToString("yyyy/MM/dd") + "','yyyy/MM/dd') AND bgcode IN (SELECT depcode FROM GDS_SC_DEPARTMENT WHERE levelcode = '0' and companyid='" + CurrentUserInfo.CompanyId + "')";
                        UserOTType = wfaddt.GetValue(condition);

                        if (UserOTType.Length == 0)
                        {
                            break;
                        }
                        if (UserOTType.Equals("Y"))
                        {
                            i += 1;
                        }
                        else
                        {
                            WorkDays += 1;
                        }
                    }
                    OTMAdvanceBeforeDays = Convert.ToString(i + WorkDays);
                }
                condition = "select trunc(sysdate)-to_date('" + OTDate + "','yyyy/mm/dd') from dual";
                strtemp = wfaddt.GetValue(condition);

                if (Convert.ToDouble(strtemp) > (Convert.ToDouble(OTMAdvanceBeforeDays)))
                {
                    this.WriteMessage(1, Message.otm_message_checkadvancedaysbefore + ":" + OTMAdvanceBeforeDays);
                    return;
                }
                string tmpOTType = FindOTType(OTDate, WorkNo);
                //if (tmpOTType.Length == 0)
                //{
                //    this.WriteMessage(1, "加班類型" + "不能為空.");
                //    return;
                //}

                #region 龍華總部周邊HR。G2,G3名稱更改為G2(休息日上班),G3(法定假日上班) update by xukai 20111010
                string LHZBIsDisplayG2G3 = "";
                try
                {
                    LHZBIsDisplayG2G3 = System.Configuration.ConfigurationManager.AppSettings["LHZBIsDisplayG2G3"];
                }
                catch
                {
                    LHZBIsDisplayG2G3 = "N";
                }

                if (LHZBIsDisplayG2G3 == "Y")
                {
                    tmpOTType = tmpOTType.Substring(0, 2);
                }
                #endregion

                double OTHours = 0;
                string strOTHours = "";
                try
                {
                    OTHours = Convert.ToDouble(this.textBoxHours.Text.Trim());
                    strOTHours = GetOTHours(WorkNo, OTDate, StrBtime, StrEtime, tmpOTType);
                }
                catch (System.Exception)
                {
                    this.WriteMessage(1, Message.otm_errorhours);
                    return;
                }

                //抓取班別
                ShiftNo = wfaddt.GetShiftNo(WorkNo, OTDate);
                if (ShiftNo == null || ShiftNo == "")
                {
                    this.WriteMessage(1, Message.otm_exception_errorshiftno_1);
                    return;
                }
                SortedList list = new SortedList();
                list = wfaddt.ReturnOTTTime(WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, ShiftNo);

                dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A")));
                dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B")));

                //請假中不能申報加班CheckLeaveOverTime
                if (!this.CheckLeaveOverTime(WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd"), dtTempBeginTime.ToString("HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd"), dtTempEndTime.ToString("HH:mm")))
                {
                    this.WriteMessage(1, Message.common_message_Leaveovertime_repeart);
                    return;
                }

                //G3加班后一天如果是正常上班不允許跨天申報Modify by Jackzhang2011/4/2
                if (!this.CheckG3WorkTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), tmpOTType))
                {
                    this.WriteMessage(1, Message.common_message_otm_worktime_checkg3);//加班時間段內含有正常工作時間,零點以后不允許申報加班
                    return;
                }

                //工作時間內不能預報加班CheckWorkTime
                if (!this.CheckWorkTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo))
                {
                    this.WriteMessage(1, Message.common_message_otm_worktime_repeart);
                    return;
                }
                if (Convert.ToDouble(strOTHours) < 0.5)
                {
                    this.WriteMessage(1, Message.otm_othourerror);
                    return;
                }
                //判斷相同時段是否有參加教育訓練
                if (!this.CheckOTOverETM(WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm")))
                {
                    this.WriteMessage(1, Message.common_message_otm_etmrepeart);
                    return;
                }
                //獲取加班異常信息
                string OTMSGFlag = wfaddt.GetOTMSGFlag(WorkNo, OTDate, Convert.ToDouble(strOTHours), tmpOTType, "Y", this.HiddenID.Value);
                string tmpRemark = "";
                if (OTMSGFlag != "")
                {
                    tmpRemark = OTMSGFlag.Substring(1, OTMSGFlag.Length - 1);
                    OTMSGFlag = OTMSGFlag.Substring(0, 1);
                }
                if (OTMSGFlag.Equals("A"))
                {
                    this.WriteMessage(1, tmpRemark);
                    return;
                }
                if (this.ProcessFlag.Value.Equals("Add"))
                {
                    //一天内多笔加班时间不能交叉或重复
                    if (!this.CheckOverTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo, true))
                    {
                        this.WriteMessage(1, Message.common_message_otm_multi_repeart);
                        return;
                    }
                    this.tempDataTable = wfaddt.GetDataByCondition_1("and 1=2").Tables["OTM_AdvanceApply"];
                    if (this.tempDataTable.Rows.Count > 0)
                    {
                        this.WriteMessage(1, Message.common_message_duplicate);
                        return;
                    }
                    System.Data.DataRow row = this.tempDataTable.NewRow();
                    row.BeginEdit();
                    row["WORKNO"] = WorkNo;
                    row["OTDate"] = OTDate;
                    row["BeginTime"] = dtTempBeginTime;
                    row["EndTime"] = dtTempEndTime;
                    row["Hours"] = strOTHours;
                    row["OTType"] = tmpOTType;
                    row["WorkDesc"] = MoveSpecailChar(this.textBoxWorkDesc.Text);
                    row["Remark"] = tmpRemark;
                    row["OTMSGFlag"] = OTMSGFlag;
                    row["ApplyDate"] = DateTime.Parse(this.textBoxApplyDate.Text.Trim().ToString()).ToString(this.dateFormat);
                    row["IsProject"] = "Y";
                    row["OTShiftNo"] = ShiftNo;
                    row["UPDATE_USER"] = CurrentUserInfo.Personcode;
                    row["Status"] = "0";
                    row.EndEdit();
                    this.tempDataTable.Rows.Add(row);
                    this.tempDataTable.AcceptChanges();
                    wfaddt.SaveData(this.ProcessFlag.Value, this.tempDataTable,logmodel);
                    this.HiddenSave.Value = "Save";
                }
                else if (ProcessFlag.Value.Equals("Modify"))
                {
                    string M_ID = this.HiddenID.Value;

                    //一天内多笔加班时间不能交叉或重复
                    if (!this.CheckOverTime(M_ID, WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo, true))
                    {
                        this.WriteMessage(1, Message.common_message_otm_multi_repeart);
                        return;
                    }
                    string condid = "and a.ID='" + M_ID + "'";
                    this.tempDataTable = wfaddt.GetDataByCondition_1(condid).Tables["OTM_AdvanceApply"];
                    if (this.tempDataTable.Rows.Count == 0)
                    {
                        this.WriteMessage(1, Message.AtLastOneChoose);
                        return;
                    }
                    System.Data.DataRow row = this.tempDataTable.Rows[0];
                    row.BeginEdit();
                    row["ID"] = M_ID;
                    row["WORKNO"] = WorkNo;
                    row["OTDate"] = OTDate;
                    row["BeginTime"] = dtTempBeginTime;
                    row["EndTime"] = dtTempEndTime;
                    row["Hours"] = strOTHours;
                    row["OTType"] = tmpOTType;
                    row["WorkDesc"] = MoveSpecailChar(this.textBoxWorkDesc.Text);
                    row["Remark"] = tmpRemark;
                    row["OTMSGFlag"] = OTMSGFlag;
                    row["UPDATE_USER"] = CurrentUserInfo.Personcode;
                    row["ApplyDate"] = DateTime.Parse(this.textBoxApplyDate.Text.Trim().ToString()).ToString(this.dateFormat);
                    if (this.HiddenState.Value == "3")
                        row["Status"] = "0";
                    row["OTShiftNo"] = ShiftNo;
                    row.EndEdit();
                    this.tempDataTable.AcceptChanges();
                    wfaddt.SaveData(this.ProcessFlag.Value, this.tempDataTable,logmodel);
                }

                if (this.ProcessFlag.Value == "Add")
                {
                    this.WriteMessage(1, Message.kqm_addsessn);
                    Add();
                }
                else
                {
                    Response.Write("<script type='text/javascript'>alert('" + Message.SaveSuccess + "'); window.parent.document.all.ButtonQuery.click();</script>");
                }
            }
            catch (System.Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('" + ex.Message + "')</script>");
                //this.WriteMessage(2, (ex.InnerException == null ? ex.Message : ex.InnerException.Message));
            }
        }
Пример #22
0
        private void DataUIBind()
        {
            string OrgCode = "";
            string ShiftNo = "";
            string ShiftDesc = "";
            string strTemp = "";
            string[] temVal = null;
            SortedList SListOrgCodeShiftDesc = new SortedList();
            string ShiftDate = this.textBoxBatchOtDate.Text;
            try
            {
                ShiftDate = Convert.ToDateTime(ShiftDate).ToString("yyyy/MM/dd");
            }
            catch (Exception)
            {
                ShiftDate = DateTime.Now.ToString("yyyy/MM/dd");
            }
            foreach (DataRow dr in this.tempDataTable.Rows)
            {
                OrgCode = dr["dCode"].ToString();
                if (Convert.ToString(dr["ShiftDesc"]).Length == 0)
                {
                    if (SListOrgCodeShiftDesc.IndexOfKey(OrgCode) >= 0)
                    {
                        ShiftDesc = SListOrgCodeShiftDesc.GetByIndex(SListOrgCodeShiftDesc.IndexOfKey(OrgCode)).ToString();
                        if (ShiftDesc.Length > 0)
                        {
                            dr["ShiftDesc"] = ShiftDesc;
                            dr["ShiftFlag"] = "N";
                        }
                    }
                    else
                    {
                        strTemp = bll.GetEmpOrgShift(OrgCode, ShiftDate);
                        if (strTemp.Length > 0)
                        {
                            temVal = strTemp.Split(new char[] { '|' });
                            ShiftNo = temVal[0].ToString();
                            if (ShiftNo.Length > 0)
                            {
                                ShiftDesc = bll.GetValue("select ShiftDesc from (select ShiftNo||':'||ShiftDesc||'['||(select dataValue from GDS_ATT_TYPEDATA b where b.datatype='ShiftType' and b.datacode=a.shifttype)||']' ShiftDesc from GDS_ATT_WORKSHIFT a  where a.ShiftNo='" + ShiftNo + "')") + "(" + temVal[4].ToString() + ")";
                                dr["ShiftDesc"] = ShiftDesc;
                                dr["ShiftFlag"] = "N";
                                SListOrgCodeShiftDesc.Add(OrgCode, ShiftDesc);
                            }
                            else
                            {
                                SListOrgCodeShiftDesc.Add(OrgCode, "");
                            }
                        }
                        else
                        {
                            SListOrgCodeShiftDesc.Add(OrgCode, "");
                        }
                    }
                }
            }

            if (this.tempDataTable == null || this.tempDataTable.Rows.Count==0)
            {
                DataTable dt = new DataTable();
                dt = new DataTable();
                dt.Columns.Add("WorkNo", Type.GetType("System.String"));
                dt.Columns.Add("LocalName", Type.GetType("System.String"));
                dt.Columns.Add("OverTimeType", Type.GetType("System.String"));
                dt.Columns.Add("ShiftDesc", Type.GetType("System.String"));
                DataRow rw01 = dt.NewRow();
                rw01["WorkNo"] = "F3228771 ";
                rw01["LocalName"] = "李玉亭";
                rw01["OverTimeType"] = "A2";
                rw01["ShiftDesc"] = "Test";
                dt.Rows.Add(rw01);

                this.tempDataTable = dt;

            }

            this.tempDataTable.DefaultView.Sort = "ShiftDesc ASC";
            this.GridEmployee.DataSource = this.tempDataTable;
            this.GridEmployee.DataBind();
        }
Пример #23
0
        public double GetOtHours(string WorkNo, string OTDate, string StrBtime, string StrEtime, string OTType)
        {
            try
            {
                double OtHours = 0.0;
                double RestHours = 0.0;
                string condition = "";
                if (OTType.Length != 0)
                {
                    DateTime dtTempBeginTime;
                    DateTime dtTempEndTime;
                    string dtShiftOnTime;
                    string dtShiftOffTime;
                    string dtAMRestSTime;
                    string dtAMRestETime;
                    TimeSpan tsOTHours;
                    if (OTType.Equals("G4") && (TimeSpan.Parse(Convert.ToDateTime(StrBtime).ToString("HH:mm")) < TimeSpan.Parse("06:30")))
                    {
                        OTDate = Convert.ToDateTime(OTDate).AddDays(-1.0).ToString("yyyy/MM/dd");
                    }
                    string strShiftNo = exceptionQryBll.GetShiftNo(WorkNo.ToUpper(), OTDate);
                    if (strShiftNo.Length == 0)
                    {
                        return OtHours;
                    }
                    if ((StrBtime.Length > 8) & (StrEtime.Length > 8))
                    {
                        dtTempBeginTime = DateTime.Parse(StrBtime);
                        dtTempEndTime = DateTime.Parse(StrEtime);
                    }
                    else
                    {
                        dtTempBeginTime = DateTime.Parse(OTDate + " " + StrBtime);
                        dtTempEndTime = DateTime.Parse(OTDate + " " + StrEtime);
                        SortedList list = new SortedList();
                        list = this.ReturnOTTTime(WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, strShiftNo);
                        dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A")));
                        dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B")));
                    }
                    if (OTType.Equals("G4") && !(dtTempBeginTime.ToString("yyyy/MM/dd").Equals(dtTempEndTime.ToString("yyyy/MM/dd")) || Convert.ToDateTime(StrBtime).ToString("HH:mm").Equals("00:00")))
                    {
                        return OtHours;
                    }
                    string dtBtime = dtTempBeginTime.ToString("yyyy/MM/dd HH:mm");
                    string dtEtime = dtTempEndTime.ToString("yyyy/MM/dd HH:mm");

                    DataTable sdt = exceptionQryBll.GetDataTableBySQL(strShiftNo);
                    if (sdt.Rows.Count == 0)
                    {
                        return OtHours;
                    }
                    string ShiftOnTime = Convert.ToString(sdt.Rows[0]["OnDutyTime"]);
                    string ShiftOffTime = Convert.ToString(sdt.Rows[0]["OffDutyTime"]);
                    string AMRestSTime = Convert.ToString(sdt.Rows[0]["AMRestSTime"]);
                    string AMRestETime = Convert.ToString(sdt.Rows[0]["AMRestETime"]);
                    string PMRestSTime = Convert.ToString(sdt.Rows[0]["PMRestSTime"]);
                    string PMRestETime = Convert.ToString(sdt.Rows[0]["PMRestETime"]);
                    string ShiftType = Convert.ToString(sdt.Rows[0]["ShiftType"]);
                    string dtPMRestSTime = "";
                    string dtPMRestETime = "";
                    if (TimeSpan.Parse(ShiftOnTime) < TimeSpan.Parse(ShiftOffTime))
                    {
                        dtShiftOnTime = DateTime.Parse(OTDate + " " + ShiftOnTime).ToString("yyyy/MM/dd HH:mm");
                        dtShiftOffTime = DateTime.Parse(OTDate + " " + ShiftOffTime).ToString("yyyy/MM/dd HH:mm");
                        dtAMRestSTime = DateTime.Parse(OTDate + " " + AMRestSTime).ToString("yyyy/MM/dd HH:mm");
                        dtAMRestETime = DateTime.Parse(OTDate + " " + AMRestETime).ToString("yyyy/MM/dd HH:mm");
                        if ((PMRestSTime.Length > 0) && (PMRestETime.Length > 0))
                        {
                            if (TimeSpan.Parse(PMRestSTime) <= TimeSpan.Parse(PMRestETime))
                            {
                                dtPMRestSTime = DateTime.Parse(OTDate + " " + PMRestSTime).ToString("yyyy/MM/dd HH:mm");
                                dtPMRestETime = DateTime.Parse(OTDate + " " + PMRestETime).ToString("yyyy/MM/dd HH:mm");
                            }
                            else
                            {
                                dtPMRestSTime = DateTime.Parse(OTDate + " " + PMRestSTime).ToString("yyyy/MM/dd HH:mm");
                                dtPMRestETime = DateTime.Parse(OTDate + " " + PMRestETime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm");
                            }
                        }
                    }
                    else
                    {
                        dtShiftOnTime = DateTime.Parse(OTDate + " " + ShiftOnTime).ToString("yyyy/MM/dd HH:mm");
                        dtShiftOffTime = DateTime.Parse(OTDate + " " + ShiftOffTime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm");
                        if ((TimeSpan.Parse(AMRestSTime) <= TimeSpan.Parse(AMRestETime)) && (TimeSpan.Parse(ShiftOnTime) < TimeSpan.Parse(AMRestETime)))
                        {
                            dtAMRestSTime = DateTime.Parse(OTDate + " " + AMRestSTime).ToString("yyyy/MM/dd HH:mm");
                            dtAMRestETime = DateTime.Parse(OTDate + " " + AMRestETime).ToString("yyyy/MM/dd HH:mm");
                        }
                        else if ((TimeSpan.Parse(AMRestSTime) <= TimeSpan.Parse(AMRestETime)) && (TimeSpan.Parse(ShiftOnTime) > TimeSpan.Parse(AMRestETime)))
                        {
                            dtAMRestSTime = DateTime.Parse(OTDate + " " + AMRestSTime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm");
                            dtAMRestETime = DateTime.Parse(OTDate + " " + AMRestETime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm");
                        }
                        else
                        {
                            dtAMRestSTime = DateTime.Parse(OTDate + " " + AMRestSTime).ToString("yyyy/MM/dd HH:mm");
                            dtAMRestETime = DateTime.Parse(OTDate + " " + AMRestETime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm");
                        }
                        if ((PMRestSTime.Length > 0) && (PMRestETime.Length > 0))
                        {
                            dtPMRestSTime = DateTime.Parse(OTDate + " " + PMRestSTime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm");
                            dtPMRestETime = DateTime.Parse(OTDate + " " + PMRestETime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm");
                        }
                    }
                    if (string.Compare(dtBtime, dtEtime) >= 0)
                    {
                        return OtHours;
                    }
                    if (OTType.Equals("G1"))
                    {
                        if (((string.Compare(dtBtime, dtShiftOnTime) >= 0) && (string.Compare(dtShiftOffTime, dtBtime) > 0)) || ((string.Compare(dtEtime, dtShiftOnTime) > 0) && (string.Compare(dtShiftOffTime, dtEtime) >= 0)))
                        {
                            return OtHours;
                        }
                        if (string.Compare(dtShiftOnTime, dtBtime) > 0)
                        {
                            if (string.Compare(dtEtime, dtShiftOnTime) > 0)
                            {
                                return OtHours;
                            }
                            tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime);
                            OtHours = tsOTHours.TotalMinutes;
                        }
                        else if (string.Compare(dtBtime, dtShiftOffTime) >= 0)
                        {
                            if (dtPMRestSTime.Length > 0)
                            {
                                if ((string.Compare(dtBtime, dtPMRestSTime) >= 0) && (string.Compare(dtPMRestETime, dtBtime) > 0))
                                {
                                    if ((string.Compare(dtEtime, dtPMRestSTime) > 0) && (string.Compare(dtPMRestETime, dtEtime) >= 0))
                                    {
                                        return OtHours;
                                    }
                                    tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime);
                                    OtHours = tsOTHours.TotalMinutes;
                                    tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestETime) - dtTempBeginTime);
                                    RestHours += tsOTHours.TotalMinutes;
                                }
                                else if (string.Compare(dtPMRestSTime, dtBtime) >= 0)
                                {
                                    if (string.Compare(dtPMRestSTime, dtEtime) >= 0)
                                    {
                                        tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime);
                                        OtHours = tsOTHours.TotalMinutes;
                                    }
                                    else if (string.Compare(dtPMRestETime, dtEtime) >= 0)
                                    {
                                        tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestSTime) - dtTempBeginTime);
                                        OtHours = tsOTHours.TotalMinutes;
                                    }
                                    else
                                    {
                                        tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime);
                                        OtHours = tsOTHours.TotalMinutes;
                                        tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestETime) - Convert.ToDateTime(dtPMRestSTime));
                                        RestHours = tsOTHours.TotalMinutes;
                                    }
                                }
                                else
                                {
                                    tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime);
                                    OtHours = tsOTHours.TotalMinutes;
                                }
                            }
                            else
                            {
                                tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime);
                                OtHours = tsOTHours.TotalMinutes;
                            }
                        }
                    }
                    else
                    {
                        if (string.Compare(dtShiftOnTime, dtBtime) > 0)
                        {
                            dtTempBeginTime = Convert.ToDateTime(dtShiftOnTime);
                            dtBtime = dtTempBeginTime.ToString("yyyy/MM/dd HH:mm");
                        }
                        if ((string.Compare(dtAMRestETime, dtBtime) >= 0) && (string.Compare(dtBtime, dtAMRestSTime) >= 0))
                        {
                            dtTempBeginTime = Convert.ToDateTime(dtAMRestETime);
                            dtBtime = dtTempBeginTime.ToString("yyyy/MM/dd HH:mm");
                        }
                        if ((string.Compare(dtAMRestETime, dtEtime) >= 0) && (string.Compare(dtEtime, dtAMRestSTime) >= 0))
                        {
                            dtTempEndTime = Convert.ToDateTime(dtAMRestSTime);
                            dtEtime = dtTempEndTime.ToString("yyyy/MM/dd HH:mm");
                        }
                        if ((string.Compare(dtPMRestETime, dtBtime) >= 0) && (string.Compare(dtBtime, dtPMRestSTime) >= 0))
                        {
                            dtTempBeginTime = Convert.ToDateTime(dtPMRestETime);
                            dtBtime = dtTempBeginTime.ToString("yyyy/MM/dd HH:mm");
                        }
                        if ((string.Compare(dtPMRestETime, dtEtime) >= 0) && (string.Compare(dtEtime, dtPMRestSTime) >= 0))
                        {
                            dtTempEndTime = Convert.ToDateTime(dtPMRestSTime);
                            dtEtime = dtTempEndTime.ToString("yyyy/MM/dd HH:mm");
                        }
                        if (string.Compare(dtBtime, dtEtime) >= 0)
                        {
                            return OtHours;
                        }
                        if ((string.Compare(dtAMRestSTime, dtBtime) >= 0) && (string.Compare(dtEtime, dtAMRestETime) >= 0))
                        {
                            tsOTHours = (TimeSpan)(Convert.ToDateTime(dtAMRestETime) - Convert.ToDateTime(dtAMRestSTime));
                            RestHours += tsOTHours.TotalMinutes;
                            if ((dtPMRestETime.Length > 0) && (string.Compare(dtEtime, dtPMRestETime) > 0))
                            {
                                tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestETime) - Convert.ToDateTime(dtPMRestSTime));
                                RestHours += tsOTHours.TotalMinutes;
                            }
                        }
                        else if ((dtPMRestETime.Length > 0) && ((string.Compare(dtPMRestSTime, dtBtime) > 0) && (string.Compare(dtEtime, dtPMRestETime) > 0)))
                        {
                            tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestETime) - Convert.ToDateTime(dtPMRestSTime));
                            RestHours += tsOTHours.TotalMinutes;
                        }
                        tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime);
                        OtHours = tsOTHours.TotalMinutes;
                    }
                    if (exceptionQryBll.GetValue("condition5", null, null, null, null).Equals("Y"))
                    {
                        OtHours = Math.Round((double)(Math.Floor((double)((OtHours - RestHours) / 10.0)) / 6.0), 1);
                    }
                    else
                    {
                        OtHours = Math.Round((double)(((OtHours - RestHours) / 60.0) * 100.0)) / 100.0;
                        if ((OtHours % 0.5) != 0.0)
                        {
                            double ihours = Math.Floor(OtHours);
                            if (OtHours > (ihours + 0.5))
                            {
                                OtHours = ihours + 0.5;
                            }
                            else
                            {
                                OtHours = ihours;
                            }
                        }
                    }
                    if ((OtHours >= 20.0) || (OtHours < 0.0))
                    {
                        OtHours = 0.0;
                    }
                }
                return OtHours;
            }
            catch (Exception)
            {
                return 0.0;
            }
        }
Пример #24
0
        public void TestIndexOfValueBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            //

            SortedList sl2 = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            string s1 = null;
            string s2 = null;
            string s3 = null;
            string s4 = null;

            int i = 0;
            int j = 0;
            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //  with null - should return -1
            // null val
            j = sl2.IndexOfValue((string)null);
            Assert.Equal(-1, j);

            //  invalid val - should return -1
            j = sl2.IndexOfValue("No_Such_Val");
            Assert.Equal(-1, j);

            // null is a valid value
            sl2.Add("Key_0", null);
            j = sl2.IndexOfValue(null);
            Assert.NotEqual(-1, j);

            // first occurrence check
            sl2.Add("Key_1", "Val_Same");
            sl2.Add("Key_2", "Val_Same");

            j = sl2.IndexOfValue("Val_Same");
            Assert.Equal(1, j);

            sl2.Clear();

            //   Testcase: add few key-val pairs
            for (i = 0; i < 100; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                sl2.Add(s1, s2);
            }

            //
            //   Testcase: test IndexOfVal 
            //
            for (i = 0; i < sl2.Count; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_"); //key
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_"); //value
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                //  now use IndexOfKey and IndexOfVal to obtain the same object and check
                s3 = (string)sl2.GetByIndex(sl2.IndexOfKey(s1)); //Get the index of this key and then get object
                s4 = (string)sl2.GetByIndex(sl2.IndexOfValue(s2)); //Get the index of this val and then get object
                Assert.True(s3.Equals(s4));

                // now Get using the index obtained thru IndexOfKey () and compare it with s2
                s3 = (string)sl2.GetByIndex(sl2.IndexOfKey(s1));
                Assert.True(s3.Equals(s2));
            }

            //
            // Remove a key and then check
            //
            sblMsg.Length = 0;
            sblMsg.Append("key_50");
            s1 = sblMsg.ToString();

            sl2.Remove(s1); //removes "Key_50"
            j = sl2.IndexOfValue(s1);
            Assert.Equal(-1, j);
        }
 private void CreateTreeDep()
 {
     this.UltraWebTreeDep.Nodes.Clear();
     //string moduleCode=Request.QueryString["modulecode"].ToString();
     this.tempDataTable = this.GetPersonDeptDataByModule(CurrentUserInfo.Personcode, "KQMSYS20101", CurrentUserInfo.CompanyId);
     SortedList allTreeNodes = new SortedList();
     foreach (DataRow row in this.tempDataTable.Rows)
     {
         allTreeNodes.Add(Convert.ToString(row["depcode"]), this.CreateNode(Convert.ToString(row["depcode"]), row["depname"].ToString(), Convert.ToString(row["authorized"]).Equals("Y"), Convert.ToDecimal(this.tempDataTable.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0M));
         if ((row["parentdepcode"].ToString().Trim().Length > 0) && (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0))
         {
             ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
         }
     }
     if (this.tempDataTable.Rows.Count > 0)
     {
         this.UltraWebTreeDep.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(this.tempDataTable.Rows[0]["depcode"]))));
     }
     foreach (Node node in this.UltraWebTreeDep.Nodes)
     {
         node.Expand(false);
     }
 }
Пример #26
0
        /// <summary>
        /// 加載功能模組
        /// </summary>
        private void LoadMenu()
        {
            DataTable tempTable = moduleBll.GetUserModuleList();

            this.UltraWebTreeStandardMenu.Nodes.Clear();
            SortedList allTreeNodes = new SortedList();
            //string SignFlag = ((ServiceLocator)this.Session["serviceLocator"]).GetFunctionData().GetValue("SELECT 1 FROM kqm_signemployee WHERE workno='" + this.Session["appUser"] + "' AND Flag='Y' and startdate<=trunc(sysdate) and enddate>=trunc(sysdate)");
            //bool boolRPM = false;
            //if (!((ServiceLocator)this.Session["serviceLocator"]).GetFunctionData().GetValue("Select count(1) from RPM_Employees where Status='0' and WorkNO='" + base.appUser + "'").Equals("0"))
            //{
            //    boolRPM = true;
            //}
            //bool boolPAM = false;
            //if (!((ServiceLocator)this.Session["serviceLocator"]).GetFunctionData().GetValue("SELECT count(1) from PAM_EmpAssess a,PAM_EmpAssessFlow b where a.Status<>'0' and a.workno=b.workno and a.workno='" + base.appUser + "' and b.assesstype='E' and a.AnnualCode in(SELECT AnnualCode from PAM_ANNUAL where assessstartdate<=trunc(sysdate) and assessenddate>=trunc(sysdate))").Equals("0"))
            //{
            //    boolPAM = true;
            //}
            //bool bPCMSYS29 = !((ServiceLocator)this.Session["serviceLocator"]).GetFunctionData().GetValue("SELECT count(1) from HRM_EmpLeaveDetail a,HRM_Employees b,HRM_EmpLeaveMaster c where b.WorkNo=a.WorkNo and c.BillNo =a.BillNo AND c.status='A00' and a.workno='" + base.appUser + "' ").Equals("0");
            foreach (DataRow row in tempTable.Rows)
            {
                if (((Convert.ToString(row["modulecode"]).Equals("PCMSYS13") || Convert.ToString(row["modulecode"]).Equals("PCMSYS24")) || (Convert.ToString(row["modulecode"]).Equals("PCMSYS26") || Convert.ToString(row["modulecode"]).Equals("PCMSYS29"))) || (((!Convert.ToString(row["modulecode"]).Equals("PCMSYS13") && !Convert.ToString(row["modulecode"]).Equals("PCMSYS24")) && !Convert.ToString(row["modulecode"]).Equals("PCMSYS26")) && !Convert.ToString(row["modulecode"]).Equals("PCMSYS29")))
                {
                    Node newNode = base.CreateNode(Convert.ToString(row["modulecode"]), FunctionText.ResourceManager.GetString(row["LANGUAGE_KEY"].ToString()), false, Convert.ToDecimal(tempTable.Compute("count(modulecode)", "parentmodulecode='" + row["modulecode"] + "'")) == 0M);
                    if (Convert.ToDecimal(tempTable.Compute("count(modulecode)", "parentmodulecode='" + row["modulecode"] + "'")) == 0M)
                    {
                        if (Convert.ToString(row["url"]).ToLower().StartsWith("http") || Convert.ToString(row["url"]).ToLower().StartsWith("ftp"))
                        {
                            newNode.TargetUrl = Convert.ToString(row["url"]);
                            newNode.TargetFrame = "_blank";
                        }
                        else
                        {
                            if (row["url"].ToString().IndexOf("?") >= 0)
                            {
                                newNode.TargetUrl = BasePage.sAppPath + Convert.ToString(row["url"]) + "&ModuleCode=" + Convert.ToString(row["modulecode"]) + "&SqlDep=true";
                            }
                            else
                            {
                                newNode.TargetUrl = BasePage.sAppPath + Convert.ToString(row["url"]) + "?ModuleCode=" + Convert.ToString(row["modulecode"]) + "&SqlDep=true";
                            }
                            newNode.TargetFrame = "fMain";
                        }
                    }
                    allTreeNodes.Add(Convert.ToString(row["modulecode"]), newNode);
                    if (row["parentmodulecode"].ToString().Trim().Length > 0)
                    {
                        if (allTreeNodes.IndexOfKey(row["parentmodulecode"]) >= 0)
                        {
                            ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentmodulecode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["modulecode"])));
                        }
                    }
                    else
                    {
                        this.UltraWebTreeStandardMenu.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["modulecode"]))));
                    }
                }
            }
        }
Пример #27
0
 public void Reload()
 {
     Migrations = LoadMigrations(_migrationPath);
     EnsureSchema(_db);
     _currentVersion = Migrations.IndexOfKey((string)_db.QueryValue("SELECT Version from SchemaInfo"));
 }
Пример #28
0
        public void TestGetKeyBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            SortedList sl2 = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            string s1 = null;
            string s2 = null;

            int i = 0;
            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //    Testcase: GetKey - key at index 0 , ArgExc expected
            Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    sl2.GetKey(0);
                });

            //   Testcase: GetKey - null val, should pass
            sl2["first key"] = (string)null;
            Assert.Equal(1, sl2.Count);

            //   Testcase: vanila Set
            sl2.Clear();
            //   Testcase: add key-val pairs
            for (i = 0; i < 50; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                sl2.Add(s1, s2);
            }

            //
            //   now get their keys using GetKey
            //
            for (i = 0; i < 50; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();
                Assert.True(((string)sl2.GetKey(sl2.IndexOfKey(s1))).Equals(s1));
            }

            Assert.Equal(50, sl2.Count);
        }
Пример #29
0
    public void TestConTable() {
      SortedList list = new SortedList();
      for (int i = 0; i < 10; i++) {
	AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
	SimNode node = new SimNode(address, NatType.Public, 0);
	list[address] = node;
      }
      SimNode n0 = (SimNode) list.GetByIndex(0);
      for (int i = 1; i < 10; i++) {
	SimNode n = (SimNode) list.GetByIndex(i);
	n0.AddConnection(n, (i%2 == 0)?ConType.Near:ConType.Shortcut);
      }
      Assert.AreEqual(n0.ConnectionTable.GetConnections(ConType.Near).Count, 4);
      Assert.AreEqual(n0.ConnectionTable.GetConnections(ConType.Shortcut).Count, 5);
      Assert.AreEqual(n0.ConnectionTable.GetAllConnections().Count, 9);      

      //make sure all connections are sorted in n0 table
      ArrayList n0_con = n0.ConnectionTable.GetAllConnections();
      for (int i = 0; i < n0_con.Count; i++) {
	AHAddress target = (AHAddress) n0_con[i];
	SimNode n = (SimNode) list.GetByIndex(i+1);
	Assert.AreEqual(target, n.LocalAddress);
      }
      //connection table is sorted (fine);
      SimNode n5 = (SimNode) list.GetByIndex(5);
      int idx = n0.ConnectionTable.IndexOf(n5.LocalAddress);
      Assert.IsTrue(idx > 0);
      Assert.AreEqual(idx, 4);


      idx = n0.ConnectionTable.IndexOf(n0.LocalAddress);
      Assert.IsTrue(idx < 0);
      idx = ~idx;
      Assert.IsTrue(idx == 0);

      for (int trials = 0; trials < 100; trials++) {
	AHAddress test_address = new AHAddress(new RNGCryptoServiceProvider());
	SimNode test_node = new SimNode(test_address, NatType.Public, 0);
	list[test_address] = test_node;
	int test_idx = list.IndexOfKey(test_address);
	//address of this newly generated address
	idx = n0.ConnectionTable.IndexOf(test_address);
	Assert.IsTrue(idx < 0);
	idx = ~idx;
	if (test_idx == 0) {
	  Assert.IsTrue(idx == 0);	
	} else {
	  Assert.IsTrue(idx == test_idx - 1);
	}
	list.Remove(test_address);
      }

      //do some unit tests for LeftInclusiveCount and RightInclusiveCount;
      for (int i = 1; i < 10; i++) {
	Assert.AreEqual(i-1, n0.ConnectionTable.LeftInclusiveCount(n0.LocalAddress, (AHAddress) list.GetKey(i)));
	//Console.WriteLine(n0.ConnectionTable.RightInclusiveCount(n0.LocalAddress, (AHAddress) list.GetKey(i)));	
	Assert.AreEqual(list.Count - i - 1, n0.ConnectionTable.RightInclusiveCount(n0.LocalAddress, (AHAddress) list.GetKey(i)));


      }

      

    }
Пример #30
0
        void DotNetNuke.Entities.Modules.IPortable.ImportModule(int ModuleID, string Content, string Version, int UserID)
        {
            XmlNode xmlCategories = DotNetNuke.Common.Globals.GetContent(Content, "Categories");
            SortedList slCategories = new SortedList(xmlCategories.ChildNodes.Count);
            int intIndexID = Null.NullInteger;

            foreach (XmlNode xmlCategory in xmlCategories)
            {
                CategoryInfo categoryInfo = new CategoryInfo();
                categoryInfo.PortalID = PortalId;
                categoryInfo.CategoryName = xmlCategory["Name"].InnerText;
                categoryInfo.CategoryDescription = xmlCategory["Description"].InnerText;
                categoryInfo.Message = xmlCategory["Message"].InnerText;
                categoryInfo.Archived = Convert.ToBoolean(xmlCategory["Archived"].InnerText);
                categoryInfo.CreatedByUser = UserId.ToString();
                categoryInfo.CreatedDate = DateTime.Now;
                categoryInfo.OrderID = Convert.ToInt32(xmlCategory["OrderID"].InnerText);
                intIndexID = slCategories.IndexOfKey(Convert.ToInt32(xmlCategory["ParentCategoryID"].InnerText));
                if (intIndexID > -1)
                {
                    categoryInfo.ParentCategoryID = (int)slCategories.GetByIndex(intIndexID);
                }
                else
                {
                    categoryInfo.ParentCategoryID = -1;
                }
                slCategories.Add(Convert.ToInt32(xmlCategory["CategoryID"].InnerText), AddCategory(categoryInfo));
            }
        }
Пример #31
0
 public virtual int IndexOf(object key)
 {
     return(host.IndexOfKey(key));
 }
Пример #32
0
 public override int IndexOfKey(Object key)
 {
     lock (_root) {
         return(_list.IndexOfKey(key));
     }
 }
Пример #33
0
 private void CreateTreeModule()
 {
     DataTable dt = departmentAssignBll.GetPersonModule(rolesCode);
     this.UltraWebTreeModule.Nodes.Clear();
     SortedList allTreeNodes = new SortedList();
     foreach (DataRow row in dt.Rows)
     {
         allTreeNodes.Add(Convert.ToString(row["modulecode"]), base.CreateNode(Convert.ToString(row["modulecode"]), FunctionText.ResourceManager.GetString(row["LANGUAGE_KEY"].ToString()), false, Convert.ToDecimal(dt.Compute("count(modulecode)", "parentmodulecode='" + row["modulecode"] + "'")) == 0M));
         if ((row["parentmodulecode"].ToString().Trim().Length > 0) && (allTreeNodes.IndexOfKey(row["parentmodulecode"]) >= 0))
         {
             ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["modulecode"]))).Style.ForeColor = ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentmodulecode"]))).Style.ForeColor;
             ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentmodulecode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["modulecode"])));
         }
     }
     foreach (DataRow row in dt.Rows)
     {
         if (row["parentmodulecode"].ToString().Trim().Length == 0)
         {
             this.UltraWebTreeModule.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["modulecode"]))));
         }
     }
 }
Пример #34
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.GridSelEmployee.Rows.Count == 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('" + Message.common_message_data_no_select_employees + "')</script>");
                    //base.WriteMessage(1, base.GetResouseValue("common.message.data.no.select.employees"));
                }
                else if (((CheckData(this.textBoxOTDate.Text, Message.overtime_date) && CheckData(this.textBoxBeginTime.Text, Message.start_time)) && (CheckData(this.textBoxEndTime.Text, Message.end_time) && CheckData(this.textBoxHours.Text, Message.times))) && CheckData(this.textBoxWorkDesc.Text, Message.overtime_desc))
                {
                    int i;
                    this.tempDataTable = bll.GetDataByCondition_1("and 1=2").Tables[0];
                    int failCount = 0;
                    int successCount = 0;
                    string OTMSGFlag = "";
                    string tmpRemark = "";
                    string msg = "";
                    string condition = "";
                    string OTDate = "";
                    try
                    {
                        OTDate = DateTime.Parse(this.textBoxOTDate.Text.ToString()).ToString("yyyy/MM/dd");
                    }
                    catch (Exception)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('"+Message.ErrDate+"')</script>");
                        //base.WriteMessage(1, base.GetResouseValue("common.message.data.errordate"));
                        return;
                    }
                    string tmpOTType = "";
                    string Hour = this.textBoxHours.Text.Trim();
                    string WorkDesc = this.textBoxWorkDesc.Text;
                    string StrBtime = this.textBoxBeginTime.Text.ToString();
                    string StrEtime = this.textBoxEndTime.Text.ToString();
                    DateTime dtTempBeginTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrBtime);
                    DateTime dtTempEndTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrEtime);
                    DateTime dtMidTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " 12:00");
                    //Function CommonFun = new Function();
                    SortedList list = new SortedList();
                    string OTMAdvanceBeforeDays = bll.GetValue("select nvl(max(paravalue),'2') from GDS_SC_PARAMETER where paraname='OTMAdvanceBeforeDays'");
                    if (!bll.GetValue("select nvl(max(workno),'Y') from GDS_ATT_EMPLOYEE where workno='" + CurrentUserInfo.Personcode + "'").Equals("Y"))
                    {
                        i = 0;
                        int WorkDays = 0;
                        string UserOTType = "";
                        while (i < Convert.ToDouble(OTMAdvanceBeforeDays))
                        {
                            UserOTType = this.FindOTType(DateTime.Now.AddDays((double)((-1 - i) - WorkDays)).ToString("yyyy/MM/dd"), CurrentUserInfo.Personcode);
                            if (UserOTType.Length == 0)
                            {
                                break;
                            }
                            if (UserOTType.Equals("G1"))
                            {
                                i++;
                            }
                            else
                            {
                                WorkDays++;
                            }
                        }
                        OTMAdvanceBeforeDays = Convert.ToString((int)(i + WorkDays));
                    }
                    condition = "select trunc(sysdate)-to_date('" + OTDate + "','yyyy/mm/dd') from dual";
                    if (Convert.ToDecimal(bll.GetValue(condition)) > Convert.ToDecimal(OTMAdvanceBeforeDays))
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('"+Message.checkapproveflag+"')</script>");
                        //base.WriteMessage(1, base.GetResouseValue("otm.message.checkadvancedaysbefore") + ":" + OTMAdvanceBeforeDays);
                    }
                    else
                    {
                        for (i = 0; i < this.GridSelEmployee.Rows.Count; i++)
                        {
                            tmpRemark = "";
                            OTMSGFlag = "";
                            this.WorkNo = this.GridSelEmployee.Rows[i].Cells.FromKey("WorkNo").Text.ToString().Trim();
                            this.ShiftNo = bll.GetShiftNo(this.WorkNo, OTDate);
                            dtTempBeginTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrBtime);
                            dtTempEndTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrEtime);
                            dtMidTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " 12:00");
                            if ((this.ShiftNo == null) || (this.ShiftNo == ""))
                            {
                                msg = msg + "<br>" + this.WorkNo + ": " + Message.otm_exception_errorshiftno_1;
                                failCount++;
                                this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                            }
                            else
                            {
                                tmpOTType = this.FindOTType(OTDate, this.WorkNo);
                                if (tmpOTType.Length == 0)
                                {
                                    msg = msg + "<br>" + this.WorkNo + ": " + Message.OTMType + Message.Required;
                                    failCount++;
                                    this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                }
                                else
                                {
                                    Hour = this.GetOTHours(this.WorkNo, OTDate, StrBtime, StrEtime, tmpOTType);
                                    if (Convert.ToDouble(Hour) < 0.5)
                                    {
                                        msg = msg + "<br>" + this.WorkNo + ": " + Message.otm_othourerror;
                                        failCount++;
                                        this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                    }
                                    else
                                    {
                                        list = bll.ReturnOTTTime(this.WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, this.ShiftNo);
                                        dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A")));
                                        dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B")));
                                        if (!CheckLeaveOverTime(this.WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd"), dtTempBeginTime.ToString("HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd"), dtTempEndTime.ToString("HH:mm")))
                                        {
                                            msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_Leaveovertime_repeart;
                                            failCount++;
                                            this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                        }
                                        else if (!CheckWorkTime(this.WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), this.ShiftNo))
                                        {
                                            msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_worktime_repeart;
                                            failCount++;
                                            this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                        }
                                        else if (!CheckOverTime(this.WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), this.ShiftNo, true))
                                        {
                                            msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_multi_repeart;
                                            failCount++;
                                            this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                        }
                                        else if (!CheckOTOverETM(this.WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm")))
                                        {
                                            msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_etmrepeart;
                                            failCount++;
                                            this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                        }
                                        else
                                        {
                                            OTMSGFlag = GetOTMSGFlag(this.WorkNo, OTDate, Convert.ToDouble(Hour), tmpOTType, "N", "");
                                            if (OTMSGFlag != "")
                                            {
                                                tmpRemark = OTMSGFlag.Substring(1, OTMSGFlag.Length - 1);
                                                OTMSGFlag = OTMSGFlag.Substring(0, 1);
                                            }
                                            if (OTMSGFlag.Equals("A"))
                                            {
                                                msg = msg + "<br>" + this.WorkNo + ": " + tmpRemark;
                                                failCount++;
                                                this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                            }
                                            else
                                            {
                                                List<OverTimeModel> mod_list = new List<OverTimeModel>();
                                                OverTimeModel mod = new OverTimeModel();
                                                mod.Workno = this.WorkNo;
                                                mod.Applydate = Convert.ToDateTime(this.textBoxApplyDate.Text.Trim());
                                                mod.Otdate =  Convert.ToDateTime(OTDate);
                                                mod.Ottype = tmpOTType;
                                                mod.Begintime = dtTempBeginTime;
                                                mod.Endtime = dtTempEndTime;
                                                mod.Hours = Convert.ToInt32(Hour);
                                                mod.Workdesc = WorkDesc;
                                                mod.G2isforrest = "N";
                                                mod.Otshiftno = this.ShiftNo;
                                                mod.Isproject = "N";
                                                mod.Update_user = CurrentUserInfo.Personcode;
                                                mod.Update_date =  DateTime.Now;
                                                mod.Remark = tmpRemark;
                                                mod.Status = "0";
                                                mod.Otmsgflag = OTMSGFlag;
                                                mod.Update_user = CurrentUserInfo.Personcode;
                                                mod_list.Add(mod);
                                                bll.SaveData(mod_list, "Add", string.Empty);
                                                //DataRow row = this.tempDataTable.NewRow();

                                                //row.BeginEdit();
                                                //row["WORKNO"] = this.WorkNo;
                                                //row["OTDate"] = OTDate;
                                                //row["BeginTime"] = dtTempBeginTime;
                                                //row["EndTime"] = dtTempEndTime;
                                                //row["Hours"] = Hour;
                                                //row["OTType"] = tmpOTType;
                                                //row["WorkDesc"] = WorkDesc;
                                                //row["OTMSGFlag"] = OTMSGFlag;
                                                //row["Remark"] = tmpRemark;
                                                //row["ApplyDate"] = this.textBoxApplyDate.Text.Trim();
                                                //row["Modifier"] = this.Session["appUser"].ToString();
                                                //row["ModifyDate"] = DateTime.Now.ToLongDateString();
                                                //row["IsProject"] = "N";
                                                //row["OTShiftNo"] = this.ShiftNo;
                                                //row.EndEdit();
                                                //this.tempDataTable.Rows.Add(row);
                                                //this.tempDataTable.AcceptChanges();
                                              //  ((ServiceLocator)this.Session["serviceLocator"]).GetOTMAdvanceApplyData().SaveData("Add", this.tempDataTable);
                                               // this.tempDataTable.Clear();
                                                successCount++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ((failCount > 0) || (successCount > 0))
                        {
                            this.labMessage.Text = string.Concat(new object[] { Message.common_success, successCount.ToString(), ";", Message.common_fault, ";", failCount, ";", msg });
                            this.labMessage.Visible = true;
                        }
                        this.ButtonSave.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('" + ex.Message + "')</script>");
               //base.WriteMessage(2, (ex.InnerException == null) ? ex.Message : ex.InnerException.Message);
            }
        }
Пример #35
0
        public static string makeCanonicalString( string verb, string bucketName, string key, SortedList queryParams,
                                                  SortedList headers, string expires )
        {
            StringBuilder buf = new StringBuilder();
            buf.Append( verb );
            buf.Append( "\n" );

            SortedList interestingHeaders = new SortedList();
            if (headers != null)
            {
                foreach (string header in headers.Keys)
                {
                    string lk = header.ToLower();
                    if (lk.Equals("content-type") ||
                         lk.Equals("content-md5") ||
                         lk.Equals("date") ||
                         lk.StartsWith(AMAZON_HEADER_PREFIX))
                    {
                        interestingHeaders.Add(lk, headers[header]);
                    }
                }
            }
            if ( interestingHeaders[ ALTERNATIVE_DATE_HEADER ] != null )
            {
                interestingHeaders.Add( "date", "" );
            }

            // if the expires is non-null, use that for the date field.  this
            // trumps the x-amz-date behavior.
            if ( expires != null )
            {
                interestingHeaders.Add( "date", expires );
            }

            // these headers require that we still put a new line after them,
            // even if they don't exist.
            {
                string [] newlineHeaders = { "content-type", "content-md5" };
                foreach ( string header in newlineHeaders )
                {
                    if ( interestingHeaders.IndexOfKey( header ) == -1 )
                    {
                        interestingHeaders.Add( header, "" );
                    }
                }
            }

            // Finally, add all the interesting headers (i.e.: all that startwith x-amz- ;-))
            foreach ( string header in interestingHeaders.Keys )
            {
                if (header.StartsWith(AMAZON_HEADER_PREFIX))
                {
                    buf.Append(header).Append(":").Append((interestingHeaders[header] as string).Trim());
                }
                else
                {
                    buf.Append(interestingHeaders[header]);
                }
                buf.Append( "\n" );
            }

            // Build the path using the bucket and key
            buf.Append( "/" );
            if ( bucketName != null && !bucketName.Equals( "" ) )
            {
                buf.Append(bucketName);
                buf.Append( "/" );
            }

            // Append the key (it may be an empty string)
            if ( key != null && key.Length != 0 )
            {
                buf.Append( key );
            }

            // if there is an acl, logging, or torrent paramter, add them to the string.
            if (queryParams != null)
            {
                if (queryParams.IndexOfKey("acl") != -1)
                {
                    buf.Append("?acl");
                }
                else if (queryParams.IndexOfKey("torrent") != -1)
                {
                    buf.Append("?torrent");
                }
                else if (queryParams.IndexOfKey("logging") != -1)
                {
                    buf.Append("?logging");
                }
            }

            return buf.ToString();
        }
Пример #36
0
 public override int IndexOfKey(object key)
 {
     lock (host.SyncRoot) {
         return(host.IndexOfKey(key));
     }
 }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!this.CheckData(this.textBoxOTDate.Text.ToString(), Message.overtime_date) ||
                    !this.CheckData(this.textBoxBeginTime.Text, Message.start_time) ||
                    !this.CheckData(this.textBoxEndTime.Text, Message.end_time) ||
                    !this.CheckData(this.textBoxHours.Text, Message.times) ||
                    !this.CheckData(this.textBoxWorkDesc.Text, Message.overtime_desc))
                {
                    return;
                }
                string condition = "";
                string strtemp = "";
                string OTDate = "";
                try
                {
                    OTDate = DateTime.Parse(this.textBoxOTDate.Text.ToString()).ToString("yyyy/MM/dd");
                }
                catch (System.Exception)
                {
                    this.WriteMessage(1, Message.common_message_data_errordate);
                    return;
                }
                WorkNo = this.textBoxEmployeeNo.Text.ToUpper();
                string StrBtime = this.textBoxBeginTime.Text.ToString();
                string StrEtime = this.textBoxEndTime.Text.ToString();
                DateTime dtTempBeginTime = DateTime.Parse(OTDate + " " + StrBtime);
                DateTime dtTempEndTime = DateTime.Parse(OTDate + " " + StrEtime);
                //DateTime dtMidTime = DateTime.Parse(OTDate + " 12:00");

                #region 每天16:30后不讓預報加班,非工作日也不能預報加班  龍華總部周邊
                string LHZBLimitTime = "";
                string LHZBIsLimitApply = "";
                string workflag = "";
                try
                {
                    LHZBIsLimitApply = System.Configuration.ConfigurationManager.AppSettings["LHZBIsLimitAdvApplyTime"];
                    LHZBLimitTime = System.Configuration.ConfigurationManager.AppSettings["LHZBLimitTime"];
                }
                catch
                {
                    LHZBIsLimitApply = "N";
                    LHZBLimitTime = "";
                }

                if (!string.IsNullOrEmpty(LHZBLimitTime))
                {
                    //每天LHZBLimitTime時間后不能新增、修改加班預報
                    DateTime dtLimit = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + LHZBLimitTime);
                    if (dtLimit < DateTime.Now)
                    {
                        this.WriteMessage(1, Message.kqm_otm_advanceapply + LHZBLimitTime + Message.kqm_otm_advanceapply_error);
                        return;
                    }
                }

                if (LHZBIsLimitApply == "Y")
                {
                    //非工作日不能預報加班
                    workflag = bll.GetEmpWorkFlag(WorkNo, DateTime.Now.ToString("yyyy-MM-dd"));
                    if (workflag == "N")
                    {
                        this.WriteMessage(1, Message.kqm_otm_advanceapply_workflag);
                        return;
                    }
                }
                #endregion

                string OTMAdvanceBeforeDays = bll.GetValue("select nvl(sum(paravalue),'2') from GDS_SC_PARAMETER where paraname='OTMAdvanceBeforeDays'");

                int i = 0;
                int WorkDays = 0;
                string UserOTType = "";
                while (i < Convert.ToDouble(OTMAdvanceBeforeDays))
                {
                    condition = "SELECT workflag FROM GDS_ATT_BGCALENDAR WHERE workday = to_date('" + System.DateTime.Now.AddDays(-1 - i - WorkDays).ToString("yyyy/MM/dd") + "','yyyy/MM/dd') AND bgcode IN (SELECT depcode FROM GDS_SC_DEPARTMENT WHERE levelcode = '0' and companyid='" + CurrentUserInfo.CompanyId + "')";
                    UserOTType = bll.GetValue(condition);
                    if (UserOTType.Length == 0)
                    {
                        break;
                    }
                    if (UserOTType.Equals("Y"))
                    {
                        i += 1;
                    }
                    else
                    {
                        WorkDays += 1;
                    }
                }
                OTMAdvanceBeforeDays = Convert.ToString(i + WorkDays);

                condition = "select trunc(sysdate)-to_date('" + OTDate + "','yyyy/mm/dd') from dual";
                strtemp = bll.GetValue(condition);
                if (Convert.ToDecimal(strtemp) > Convert.ToDecimal(OTMAdvanceBeforeDays))
                {
                    this.WriteMessage(1, Message.otm_message_checkadvancedaysbefore + ":" + OTMAdvanceBeforeDays);
                    return;
                }
                string tmpOTType = FindOTType(OTDate, WorkNo);
                #region 龍華總部周邊HR。G2,G3名稱更改為G2(休息日上班),G3(法定假日上班)
                string LHZBIsDisplayG2G3 = "";
                try
                {
                    LHZBIsDisplayG2G3 = System.Configuration.ConfigurationManager.AppSettings["LHZBIsDisplayG2G3"];
                }
                catch
                {
                    LHZBIsDisplayG2G3 = "N";
                }

                if (LHZBIsDisplayG2G3 == "Y")
                {
                    tmpOTType = tmpOTType.Substring(0, 2);
                    //G2加班 必須要自己選擇是否調休
                    if (tmpOTType.Equals("G2"))
                    {
                        //update by xukai 20111024 總部周邊加班類型為L的,G2加班一定是調休
                        if (this.textBoxPersonType.Text.Trim().IndexOf("L") != -1)
                        {
                            this.ddlIsMoveLeave.SelectedValue = "Y"; //dropdownlist前臺disable取不到值
                        }
                        if (!this.CheckData(this.ddlIsMoveLeave.SelectedValue, Message.pcm_advanceapply_ismoveleave))
                        {
                            this.ddlIsMoveLeave.Enabled = true;
                            return;
                        }
                    }
                }
                #endregion

                double OTHours = 0;
                string strOTHours = "";
                try
                {
                    OTHours = Convert.ToDouble(this.textBoxHours.Text.Trim());
                    strOTHours = GetOTHours(WorkNo, OTDate, StrBtime, StrEtime, tmpOTType);
                }
                catch (System.Exception)
                {
                    this.WriteMessage(1, Message.otm_errorhours);
                    return;
                }
                if (Convert.ToDouble(strOTHours) < 0.5)
                {
                    this.WriteMessage(1, Message.otm_othourerror);
                    return;
                }
                if (tmpOTType.Length == 0)
                {
                    this.WriteMessage(1, Message.OTMType + Message.NotNullOrEmpty);
                    return;
                }
                //抓取班別
                ShiftNo = bll.GetShiftNo(WorkNo, OTDate);
                if (ShiftNo == null || ShiftNo == "")
                {
                    this.WriteMessage(1, Message.otm_exception_errorshiftno_1);
                    return;
                }
                SortedList list = new SortedList();
                //Function CommonFun = new Function();
                list = bll.ReturnOTTTime(WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, ShiftNo);
                dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A")));
                dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B")));
                if (this.ProcessFlag.Value.Equals("Add"))
                {
                    //一天内多笔加班时间不能交叉或重复
                    if (!CheckOverTime(WorkNo, OTDate, dtTempBeginTime.ToString(), dtTempEndTime.ToString(), ShiftNo, true))
                    {
                        this.WriteMessage(1, Message.common_message_otm_multi_repeart);
                        return;
                    }
                }
                else
                {
                    //一天内多笔加班时间不能交叉或重复
                    if (!CheckOverTime(this.HiddenID.Value, WorkNo, OTDate, dtTempBeginTime.ToString(), dtTempEndTime.ToString(), ShiftNo, true))
                    {
                        this.WriteMessage(1, Message.common_message_otm_multi_repeart);
                        return;
                    }
                }
                //請假中不能申報加班
                if (!CheckLeaveOverTime(WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd"), dtTempBeginTime.ToString("HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd"), dtTempEndTime.ToString("HH:mm")))
                {
                    this.WriteMessage(1, Message.common_message_Leaveovertime_repeart);
                    return;
                }

                //G3加班后一天如果是正常上班不允許跨天申報Modify by Jackzhang2011/4/2
                if (!CheckG3WorkTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), tmpOTType))
                {
                    this.WriteMessage(1, Message.common_message_otm_worktime_checkg3);//加班時間段內含有正常工作時間,零點以后不允許申報加班
                    return;
                }

                //工作時間內不能預報加班
                if (!CheckWorkTime(WorkNo, OTDate, dtTempBeginTime.ToString(), dtTempEndTime.ToString(), ShiftNo))
                {
                    this.WriteMessage(1, Message.common_message_otm_worktime_repeart);
                    return;
                }
                //判斷相同時段是否有參加教育訓練
                if (!CheckOTOverETM(WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm")))
                {
                    this.WriteMessage(1, Message.common_message_otm_etmrepeart);
                    return;
                }
                if (this.ProcessFlag.Value.Equals("Add"))
                {
                    this.HiddenIsProject.Value = this.ddlIsProject.SelectedValue;
                }
                //獲取加班異常信息
                string OTMSGFlag = GetOTMSGFlag(WorkNo, OTDate, Convert.ToDouble(strOTHours), tmpOTType, this.HiddenIsProject.Value, this.HiddenID.Value);
                string tmpRemark = "";
                if (OTMSGFlag != "")
                {
                    tmpRemark = OTMSGFlag.Substring(1, OTMSGFlag.Length - 1);
                    OTMSGFlag = OTMSGFlag.Substring(0, 1);
                }
                if (OTMSGFlag.Equals("A"))
                {
                    this.WriteMessage(1, tmpRemark);
                    return;
                }
                if (this.ProcessFlag.Value.Equals("Add"))
                {
                    ////一天内多笔加班时间不能交叉或重复
                    //if (!CommonFun.CheckOverTime(WorkNo, OTDate, dtTempBeginTime.ToString(), dtTempEndTime.ToString(), ShiftNo, true))
                    //{
                    //    this.WriteMessage(1, this.GetResouseValue("common.message.otm.multi.repeart"));
                    //    return;
                    //}
                    //有未核準的加班申請單據,不能再申請
                    //condition = "and a.WorkNo='" + WorkNo + "' and a.Status in ('0','1') and a.ottype='" + tmpOTType + "'";
                    //this.tempDataTable = ((eBFW.Sys.ServiceLocator)Session["serviceLocator"]).GetOTMAdvanceApplyData().GetDataByCondition(condition).Tables["KQM_LeaveApply"];
                    //if (this.tempDataTable.Rows.Count > 0)
                    //{
                    //    this.WriteMessage(1, this.GetResouseValue("otm.advanceapply.checkrepeatstatus"));
                    //    return;
                    //}

                    this.tempDataTable = bll.GetDataByCondition_1("and 1=2").Tables["OTM_AdvanceApply"];
                    if (this.tempDataTable.Rows.Count > 0)
                    {
                        this.WriteMessage(1, Message.common_message_duplicate);
                        return;
                    }
                    System.Data.DataRow row = this.tempDataTable.NewRow();
                    row.BeginEdit();
                    row["WORKNO"] = WorkNo;
                    row["OTDate"] = OTDate;
                    row["BeginTime"] = dtTempBeginTime;
                    row["EndTime"] = dtTempEndTime;
                    row["Hours"] = strOTHours;
                    row["OTType"] = tmpOTType;
                    row["WorkDesc"] = MoveSpecailChar(this.textBoxWorkDesc.Text);
                    row["Remark"] = tmpRemark;
                    row["OTMSGFlag"] = OTMSGFlag;
                    row["UPDATE_USER"] = CurrentUserInfo.Personcode;
                    row["ApplyDate"] = DateTime.Parse(this.textBoxApplyDate.Text.Trim().ToString()).ToString("yyyy/MM/dd");
                    if (this.ddlIsProject.SelectedValue.Equals("N"))
                    {
                        row["IsProject"] = "N";
                    }
                    else
                    {
                        row["IsProject"] = "Y";
                    }
                    row["OTShiftNo"] = ShiftNo;
                    row["Status"] = "0";
                    #region   G2加班是否用於調休
                    string g2isforrest = "";
                    //是否顯示是否調休
                    string isShowMoveLeaveFlag = bll.GetValue("select nvl(max(paravalue),'N') from GDS_SC_PARAMETER where paraname='IsShowMoveLeaveFlag'");
                    if (isShowMoveLeaveFlag.Equals("Y"))
                    {
                        if (tmpOTType == "G2")
                        {
                            g2isforrest = this.ddlIsMoveLeave.SelectedValue;
                            //update by xukai 20111024 總部周邊加班類型為L的,G2加班一定是調休
                            if (this.textBoxPersonType.Text.Trim().IndexOf("L") != -1)
                            {
                                g2isforrest = "Y";
                            }
                            //end
                        }
                        else
                        {
                            g2isforrest = "N";
                        }
                        row["G2ISFORREST"] = g2isforrest;
                    }
                    #endregion

                    row.EndEdit();
                    this.tempDataTable.Rows.Add(row);
                    this.tempDataTable.AcceptChanges();
                    bll.SaveData(this.ProcessFlag.Value, this.tempDataTable,logmodel);
                    this.HiddenSave.Value = "Save";

                    ////通知考勤窗口
                    //if (this.ddlWindow.SelectedValue.Length > 0)
                    //{
                    //    string RemindContent = this.textBoxDPcode.Text + ":" + WorkNo + this.textBoxLocalName.Text +
                    //        "在" + this.GetResouseValue(this.moduleCode) +
                    //        "中申請了" + this.textBoxOTDate.Text + "加班";
                    //    ((eBFW.Sys.ServiceLocator)Session["serviceLocator"]).GetFunctionData().ExcuteSQL("INSERT INTO WFM_REMIND (WORKNO, REMINDCONTENT, REMINDDATE,FLAG)VALUES('" + this.ddlWindow.SelectedValue + "','" + RemindContent + "',sysdate,'N')");
                    //}
                }
                else if (ProcessFlag.Value.Equals("Modify"))
                {
                    ////一天内多笔加班时间不能交叉或重复
                    //if (!CommonFun.CheckOverTime(this.HiddenID.Value, WorkNo, OTDate, dtTempBeginTime.ToString(), dtTempEndTime.ToString(), ShiftNo, true))
                    //{
                    //    this.WriteMessage(1, this.GetResouseValue("common.message.otm.multi.repeart"));
                    //    return;
                    //}
                    //有未核準的加班申請單據,不能再申請
                    //condition = "and a.WorkNo='" + WorkNo + "' and a.Status in ('0','1') and a.ottype='" + tmpOTType + "' and a.ID<>'" + M_ID + "'";
                    //this.tempDataTable = ((eBFW.Sys.ServiceLocator)Session["serviceLocator"]).GetOTMAdvanceApplyData().GetDataByCondition(condition).Tables["KQM_LeaveApply"];
                    //if (this.tempDataTable.Rows.Count > 0)
                    //{
                    //    this.WriteMessage(1, this.GetResouseValue("otm.advanceapply.checkrepeatstatus"));
                    //    return;
                    //}

                    this.tempDataTable = bll.GetDataByCondition_1("and a.ID='" + this.HiddenID.Value + "'").Tables["OTM_AdvanceApply"];
                    if (this.tempDataTable.Rows.Count == 0)
                    {
                        this.WriteMessage(1, Message.AtLastOneChoose);
                        return;
                    }
                    System.Data.DataRow row = this.tempDataTable.Rows[0];
                    row.BeginEdit();
                    row["ID"] = this.HiddenID.Value;
                    row["WORKNO"] = WorkNo;
                    row["OTDate"] = OTDate;
                    row["BeginTime"] = dtTempBeginTime;
                    row["EndTime"] = dtTempEndTime;
                    row["Hours"] = strOTHours;
                    row["OTType"] = tmpOTType;
                    row["WorkDesc"] = MoveSpecailChar(this.textBoxWorkDesc.Text);
                    row["Remark"] = tmpRemark;
                    row["OTMSGFlag"] = OTMSGFlag;
                    row["UPDATE_USER"] = CurrentUserInfo.Personcode;
                    row["ApplyDate"] = DateTime.Parse(this.textBoxApplyDate.Text.Trim().ToString()).ToString("yyyy/MM/dd");
                    if (this.HiddenState.Value == "3")
                        row["Status"] = "0";
                    row["OTShiftNo"] = ShiftNo;
                    #region  G2加班是否用於調休
                    string g2isforrest = "";
                    //是否顯示是否調休
                    string isShowMoveLeaveFlag = bll.GetValue("select nvl(max(paravalue),'N') from GDS_SC_PARAMETER where paraname='IsShowMoveLeaveFlag'");
                    if (isShowMoveLeaveFlag.Equals("Y"))
                    {
                        if (tmpOTType == "G2")
                        {
                            g2isforrest = this.ddlIsMoveLeave.SelectedValue;
                            //update by xukai 20111024 總部周邊加班類型為L的,G2加班一定是調休
                            if (this.textBoxPersonType.Text.Trim().IndexOf("L") != -1)
                            {
                                g2isforrest = "Y";
                            }
                            //end
                        }
                        else
                        {
                            g2isforrest = "N";
                        }
                        row["G2ISFORREST"] = g2isforrest;
                    }
                    #endregion
                    row.EndEdit();
                    this.tempDataTable.AcceptChanges();
                    bll.SaveData(this.ProcessFlag.Value, this.tempDataTable,logmodel);
                }
                if (tmpRemark.Length > 0)
                {
                    Response.Write("<script type='text/javascript'>alert('" + Message.DataSaveSuccess + ":" + tmpRemark + "');window.parent.document.all.ButtonQuery.click();</script>");
                }
                else
                {
                    Response.Write("<script type='text/javascript'>alert('" + Message.DataSaveSuccess + "');window.parent.document.all.ButtonQuery.click();</script>");
                }
            }
            catch (System.Exception ex)
            {
                this.WriteMessage(2, (ex.InnerException == null ? ex.Message : ex.InnerException.Message));
            }
        }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            //List<OverTimeModel> list = new List<OverTimeModel>();
            //OverTimeModel mod = new OverTimeModel();
            //mod.Workno = textBoxEmployeeNo.Text.Trim();
            //mod.Applydate = Convert.ToDateTime(textBoxApplyDate.Text.Trim());
            //mod.Otdate = Convert.ToDateTime(textBoxOTDate.Text.Trim());
            //mod.Ottype = textBoxOTType.Text.Trim();
            //mod.Begintime = Convert.ToDateTime(textBoxBeginTime.Text.Trim());
            //mod.Endtime = Convert.ToDateTime(textBoxEndTime.Text.Trim());
            //mod.Hours = Convert.ToInt32(textBoxHours.Text.Trim());
            //mod.Workdesc = textBoxWorkDesc.Text.Trim();
            //mod.G2isforrest = ddlIsMoveLeave.SelectedValue;
            //mod.Otshiftno = textBoxPersonType.Text;
            //mod.Status = "0";
            //list.Add(mod);
            //string ProcessFlag = this.Request.QueryString["ProcessFlag"] == null ? "" : this.Request.QueryString["ProcessFlag"].ToString();
            //string ID = this.Request.QueryString["ID"] == null ? "" : this.Request.QueryString["ID"].ToString();
            //OverTimeBll bll = new OverTimeBll();
            //if (ProcessFlag == "Add")
            //{

            //    if (bll.SaveData(list, ProcessFlag, ID))
            //    {
            //        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功!');</script>");
            //    }
            //    else
            //    {
            //        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存失敗!');</script>");
            //    }
            //}
            //else
            //{
            //    if (bll.SaveData(list, ProcessFlag, ID))
            //    {
            //        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功!');</script>");
            //    }
            //    else
            //    {
            //        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存失敗!');</script>");
            //    }
            //}

            try
            {
                if (!this.CheckData(this.textBoxOTDate.Text.ToString(), Message.overtime_date) ||
                    !this.CheckData(this.textBoxBeginTime.Text, Message.start_time) ||
                    !this.CheckData(this.textBoxEndTime.Text, Message.end_time) ||
                    !this.CheckData(this.textBoxHours.Text, Message.times) ||
                    !this.CheckData(this.textBoxWorkDesc.Text, Message.overtime_desc))
                {
                    return;
                }
                string condition = "";
                string strtemp = "";
                string OTDate = "";
               // Function CommonFun = new Function();
                try
                {
                    OTDate = DateTime.Parse(this.textBoxOTDate.Text.ToString()).ToString("yyyy/MM/dd");
                }
                catch (System.Exception)
                {
                    this.WriteMessage(1, Message.common_message_data_errordate);
                    return;
                }
                if (!this.textBoxOTType.Equals("G2"))
                {
                    this.textBoxPlanAdjust.Text = "";
                }
                WorkNo = this.textBoxEmployeeNo.Text.ToUpper();
                string StrBtime = this.textBoxBeginTime.Text.ToString();
                string StrEtime = this.textBoxEndTime.Text.ToString();
                DateTime dtTempBeginTime = DateTime.Parse(OTDate + " " + StrBtime);
                DateTime dtTempEndTime = DateTime.Parse(OTDate + " " + StrEtime);
                //DateTime dtMidTime = DateTime.Parse(OTDate + " 12:00");
                //string IsAllowModifyOTReal = ((eBFW.Sys.ServiceLocator)Session["serviceLocator"]).GetFunctionData().GetValue("select nvl(max(paravalue),'N') from bfw_parameter where paraname='IsAllowModifyOTReal'");

                //助理先取消
                //#region 每天16:30后不讓預報加班,非工作日也不能預報加班  龍華總部周邊 update by xukai 20111014
                //string LHZBLimitTime = "";
                //string LHZBIsLimitApply = "";
                //string workflag = "";
                //try
                //{
                //    LHZBIsLimitApply = System.Configuration.ConfigurationManager.AppSettings["LHZBIsLimitAdvApplyTime"];
                //    LHZBLimitTime = System.Configuration.ConfigurationManager.AppSettings["LHZBLimitTime"];
                //}
                //catch
                //{
                //    LHZBIsLimitApply = "N";
                //    LHZBLimitTime = "";
                //}

                //if (!string.IsNullOrEmpty(LHZBLimitTime))
                //{
                //    //每天LHZBLimitTime時間后不能新增、修改加班預報
                //    DateTime dtLimit = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + LHZBLimitTime);
                //    if (dtLimit < DateTime.Now)
                //    {
                //        this.WriteMessage(1, this.GetResouseValue("kqm.otm.advanceapply") + LHZBLimitTime + this.GetResouseValue("kqm.otm.advanceapply.error"));
                //        return;
                //    }
                //}

                //if (LHZBIsLimitApply == "Y")
                //{
                //    //非工作日不能預報加班
                //    workflag = ((eBFW.Sys.ServiceLocator)Session["serviceLocator"]).GetFunctionData().GetEmpWorkFlag(WorkNo, DateTime.Now.ToString("yyyy-MM-dd"));
                //    if (workflag == "N")
                //    {
                //        this.WriteMessage(1, this.GetResouseValue("kqm.otm.advanceapply.workflag"));
                //        return;
                //    }
                //}
                //#endregion
                string OTMAdvanceBeforeDays = bll.GetValue("select nvl(max(paravalue),'2') from GDS_SC_PARAMETER where paraname='OTMAdvanceBeforeDays'");
                string appUserIsIn = bll.GetValue("select nvl(max(workno),'Y') from GDS_ATT_employee where workno='" + CurrentUserInfo.Personcode + "'");
                if (!appUserIsIn.Equals("Y"))//允許申報當前日期以前多少天的加班除去非工作日
                {
                    int i = 0;
                    int WorkDays = 0;
                    string UserOTType = "";
                    while (i < Convert.ToDouble(OTMAdvanceBeforeDays))
                    {
                        condition = "SELECT workflag FROM GDS_ATT_BGCALENDAR WHERE workday = to_date('" + System.DateTime.Now.AddDays(-1 - i - WorkDays).ToString("yyyy/MM/dd") + "','yyyy/MM/dd') AND bgcode IN (SELECT depcode FROM GDS_SC_DEPARTMENT WHERE levelcode = '0' and companyid='" + CurrentUserInfo.CompanyId + "')";
                        UserOTType = bll.GetValue(condition);
                        if (UserOTType.Length == 0)
                        {
                            break;
                        }
                        if (UserOTType.Equals("Y"))
                        {
                            i += 1;
                        }
                        else
                        {
                            WorkDays += 1;
                        }
                    }
                    OTMAdvanceBeforeDays = Convert.ToString(i + WorkDays);
                }
                condition = "select trunc(sysdate)-to_date('" + OTDate + "','yyyy/mm/dd') from dual";
                strtemp = bll.GetValue(condition);
                if (Convert.ToDouble(strtemp) > (Convert.ToDouble(OTMAdvanceBeforeDays)))
                {
                    this.WriteMessage(1, Message.otm_message_checkadvancedaysbefore + ":" + OTMAdvanceBeforeDays);
                    return;
                }
                string tmpOTType = FindOTType(OTDate, WorkNo);
                if (tmpOTType.Length == 0)
                {
                    this.WriteMessage(1, Message.OTMType + Message.Required);
                    return;
                }

                #region 龍華總部周邊HR。G2,G3名稱更改為G2(休息日上班),G3(法定假日上班) update by xukai 20111010
                string LHZBIsDisplayG2G3 = "";
                try
                {
                    LHZBIsDisplayG2G3 = System.Configuration.ConfigurationManager.AppSettings["LHZBIsDisplayG2G3"];
                }
                catch
                {
                    LHZBIsDisplayG2G3 = "N";
                }

                if (LHZBIsDisplayG2G3 == "Y")
                {
                    tmpOTType = tmpOTType.Substring(0, 2);
                }
                #endregion

                double OTHours = 0;
                string strOTHours = "";
                try
                {
                    OTHours = Convert.ToDouble(this.textBoxHours.Text.Trim());
                    strOTHours = GetOTHours(WorkNo, OTDate, StrBtime, StrEtime, tmpOTType);
                }
                catch (System.Exception)
                {
                    this.WriteMessage(1, Message.otm_errorhours);
                    return;
                }

                //抓取班別
                ShiftNo = bll.GetShiftNo(WorkNo, OTDate);
                if (ShiftNo == null || ShiftNo == "")
                {
                    this.WriteMessage(1, Message.otm_exception_errorshiftno_1);
                    return;
                }
                SortedList list = new SortedList();
                list = bll.ReturnOTTTime(WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, ShiftNo);
                dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A")));
                dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B")));

                if (this.ProcessFlag.Value.Equals("Add"))
                {
                    //一天内多笔加班时间不能交叉或重复
                    if (!CheckOverTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo, true))
                    {
                        this.WriteMessage(1, Message.common_message_otm_multi_repeart);
                        return;
                    }
                }
                else
                {
                    //一天内多笔加班时间不能交叉或重复
                    if (!CheckOverTime(this.HiddenID.Value, WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo, true))
                    {
                        this.WriteMessage(1, Message.common_message_otm_multi_repeart);
                        return;
                    }
                }
                //請假中不能申報加班
                if (!CheckLeaveOverTime(WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd"), dtTempBeginTime.ToString("HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd"), dtTempEndTime.ToString("HH:mm")))
                {
                    this.WriteMessage(1, Message.common_message_Leaveovertime_repeart);
                    return;
                }

                //工作時間內不能預報加班
                if (!CheckWorkTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo))
                {
                    this.WriteMessage(1, Message.common_message_otm_worktime_repeart);
                    return;
                }

                //G3加班后一天不允許跨天申報Modify by Jackzhang2011/4/2
                if (!CheckG3WorkTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), tmpOTType))
                {
                    this.WriteMessage(1, Message.kqm_otm_g3kuantian);//加班時間段內含有正常工作時間,零點以后不允許申報加班
                    return;
                }

                if (Convert.ToDouble(strOTHours) < 0.5)
                {
                    this.WriteMessage(1, Message.otm_othourerror);
                    return;
                }

                //判斷相同時段是否有參加教育訓練
                if (!CheckOTOverETM(WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm")))
                {
                    this.WriteMessage(1, Message.common_message_otm_etmrepeart);
                    return;
                }
                //獲取加班異常信息
                string OTMSGFlag = GetOTMSGFlag(WorkNo, OTDate, Convert.ToDouble(strOTHours), tmpOTType, "N", this.HiddenID.Value);
                string tmpRemark = "";
                if (OTMSGFlag != "")
                {
                    tmpRemark = OTMSGFlag.Substring(1, OTMSGFlag.Length - 1);
                    OTMSGFlag = OTMSGFlag.Substring(0, 1);
                }
                if (OTMSGFlag.Equals("A"))
                {
                    this.WriteMessage(1, tmpRemark);
                    return;
                }
                if (this.ProcessFlag.Value.Equals("Add"))
                {
                    ////一天内多笔加班时间不能交叉或重复
                    //if (!CommonFun.CheckOverTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo, true))
                    //{
                    //    this.WriteMessage(1, this.GetResouseValue("common.message.otm.multi.repeart"));
                    //    return;
                    //}
                    this.tempDataTable = bll.GetDataByCondition_1("and 1=2").Tables["OTM_AdvanceApply"];
                    if (this.tempDataTable.Rows.Count > 0)
                    {
                        this.WriteMessage(1, Message.common_message_duplicate);
                        return;
                    }
                    System.Data.DataRow row = this.tempDataTable.NewRow();
                    row.BeginEdit();
                    row["WORKNO"] = WorkNo;
                    row["OTDate"] = OTDate;
                    row["BeginTime"] = dtTempBeginTime;
                    row["EndTime"] = dtTempEndTime;
                    row["Hours"] = strOTHours;
                    row["OTType"] = tmpOTType;
                    row["WorkDesc"] = MoveSpecailChar(this.textBoxWorkDesc.Text);
                    row["Remark"] = tmpRemark;
                    row["OTMSGFlag"] = OTMSGFlag;
                    row["ApplyDate"] = DateTime.Parse(this.textBoxApplyDate.Text.Trim().ToString()).ToString("yyyy/MM/dd");
                    row["IsProject"] = "N";
                    row["Status"] = "0";
                    row["OTShiftNo"] = ShiftNo;
                    row["UPDATE_USER"] = CurrentUserInfo.Personcode;

                    if (this.textBoxPlanAdjust.Text.Length == 0)
                    {
                        row["PlanAdjust"] = DBNull.Value;
                    }
                    else
                    {
                        row["PlanAdjust"] = this.textBoxPlanAdjust.Text;
                    }

                    #region xukai  2011-10-17  G2加班是否用於調休
                    string g2isforrest = "";
                    //是否顯示是否調休
                    string isShowMoveLeaveFlag = bll.GetValue("select nvl(max(paravalue),'N') from GDS_SC_PARAMETER where paraname='IsShowMoveLeaveFlag'");
                    if (isShowMoveLeaveFlag.Equals("Y"))
                    {
                        if (tmpOTType.Equals("G2"))
                        {
                            g2isforrest = this.ddlIsMoveLeave.SelectedValue;
                            //update by xukai 20111024 總部周邊加班類型為L的,G2加班一定是調休
                            if (this.textBoxPersonType.Text.Trim().IndexOf("L") != -1)
                            {
                                g2isforrest = "Y";
                            }
                            //end
                        }
                        else
                        {
                            g2isforrest = "N";
                        }
                        row["G2ISFORREST"] = g2isforrest;
                    }

                    #endregion
                    row.EndEdit();
                    this.tempDataTable.Rows.Add(row);
                    this.tempDataTable.AcceptChanges();
                    bll.SaveData(this.ProcessFlag.Value, this.tempDataTable,logmodel);
                    this.HiddenSave.Value = "Save";
                }
                else if (ProcessFlag.Value.Equals("Modify"))
                {
                    //一天内多笔加班时间不能交叉或重复
                    //if (!CommonFun.CheckOverTime(this.HiddenID.Value, WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo, true))
                    //{
                    //    this.WriteMessage(1, this.GetResouseValue("common.message.otm.multi.repeart"));
                    //    return;
                    //}

                    this.tempDataTable = bll.GetDataByCondition_1("and a.ID='" + this.HiddenID.Value + "'").Tables["OTM_AdvanceApply"];
                    if (this.tempDataTable.Rows.Count == 0)
                    {
                        this.WriteMessage(1, Message.AtLastOneChoose);
                        return;
                    }
                    System.Data.DataRow row = this.tempDataTable.Rows[0];
                    row.BeginEdit();
                    row["ID"] = this.HiddenID.Value;
                    row["WORKNO"] = WorkNo;
                    row["OTDate"] = OTDate;
                    row["BeginTime"] = dtTempBeginTime;
                    row["EndTime"] = dtTempEndTime;
                    row["Hours"] = strOTHours;
                    row["OTType"] = tmpOTType;
                    row["WorkDesc"] = MoveSpecailChar(this.textBoxWorkDesc.Text);
                    row["Remark"] = tmpRemark;
                    row["OTMSGFlag"] = OTMSGFlag;
                    row["ApplyDate"] = DateTime.Parse(this.textBoxApplyDate.Text.Trim().ToString()).ToString("yyyy/MM/dd");
                    if (this.HiddenState.Value == "3")
                        row["Status"] = "0";
                    row["OTShiftNo"] = ShiftNo;
                    row["UPDATE_USER"] = CurrentUserInfo.Personcode;
                    if (this.textBoxPlanAdjust.Text.Length == 0)
                    {
                        row["PlanAdjust"] = DBNull.Value;
                    }
                    else
                    {
                        row["PlanAdjust"] = this.textBoxPlanAdjust.Text;
                    }
                    #region xukai  2011-10-17  G2加班是否用於調休
                    string g2isforrest = "";
                    //是否顯示是否調休
                    string isShowMoveLeaveFlag = bll.GetValue("select nvl(max(paravalue),'N') from GDS_SC_PARAMETER where paraname='IsShowMoveLeaveFlag'");
                    if (isShowMoveLeaveFlag.Equals("Y"))
                    {
                        if (tmpOTType.Equals("G2"))
                        {
                            g2isforrest = this.ddlIsMoveLeave.SelectedValue;
                            //update by xukai 20111024 總部周邊加班類型為L的,G2加班一定是調休
                            if (this.textBoxPersonType.Text.Trim().IndexOf("L") != -1)
                            {
                                g2isforrest = "Y";
                            }
                            //end
                        }
                        else
                        {
                            g2isforrest = "N";
                        }
                        row["G2ISFORREST"] = g2isforrest;
                    }

                    #endregion
                    row.EndEdit();
                    this.tempDataTable.AcceptChanges();
                    bll.SaveData(this.ProcessFlag.Value, this.tempDataTable,logmodel);
                    this.WriteMessage(0, Message.SaveSuccess);
                }

                if (this.ProcessFlag.Value == "Add")
                {
                    if (tmpRemark.Length > 0)
                    {
                        this.WriteMessage(1, Message.kqm_addsessn + ":" + tmpRemark);
                    }
                    else
                    {
                        this.WriteMessage(1, Message.kqm_addsessn);
                    }
                    Add();
                }
                else
                {

                   Response.Write("<script type='text/javascript'>window.parent.document.all.btnQuery.click();</script>");

                }
            }
            catch (System.Exception ex)
            {
                this.WriteMessage(2, (ex.InnerException == null ? ex.Message : ex.InnerException.Message));
            }
        }
Пример #39
0
 private void CreateTreeDep(string DelLevel)
 {
     this.UltraWebTreeDepartment.Nodes.Clear();
     if ((this.UltraWebTreeModule.SelectedNode != null) && (this.UltraWebTreeCompany.SelectedNode != null))
     {
         string ModuleCode = Convert.ToString(this.UltraWebTreeModule.SelectedNode.Tag);
         string CompanyId = Convert.ToString(this.UltraWebTreeCompany.SelectedNode.Tag);
         DataTable dt = new DataTable();
         string Appuser = base.CurrentUserInfo.Personcode;
         modulecode = "SYS03";
         personCode = base.Request.QueryString["PersonCode"];
         dt = departmentAssignBll.GetPersonDeptDataByModule(Appuser, modulecode, personCode, ModuleCode, CompanyId, DelLevel);
         SortedList allTreeNodes = new SortedList();
         foreach (DataRow row in dt.Rows)
         {
             allTreeNodes.Add(Convert.ToString(row["depcode"]), base.CreateNode(Convert.ToString(row["depcode"]), row["depname"].ToString(), Convert.ToString(row["authorized"]).Equals("Y"), Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0M));
             if ((row["parentdepcode"].ToString().Trim().Length > 0) && (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0))
             {
                 if (!(!((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Checked && ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Enabled))
                 {
                     //((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"]))).Enabled = false;
                     //((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"]))).Checked = false;
                 }
                 ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
             }
         }
         if (dt.Rows.Count > 0)
         {
             this.UltraWebTreeDepartment.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(dt.Rows[0]["depcode"]))));
         }
     }
     foreach (Node node in this.UltraWebTreeDepartment.Nodes)
     {
         node.Expand(true);
     }
 }