Beispiel #1
0
        public void UpdateCheckboxes(HttpRequest oForm, int _resourceid, int _requestid, int _itemid, int _number)
        {
            ResourceRequest oResourceRequest = new ResourceRequest(user, dsn);
            bool            boolJoined       = (oResourceRequest.GetWorkflow(_resourceid, "joined") == "1");

            // First, uncheck the checkboxes.
            if (boolJoined)
            {
                oResourceRequest.DeleteDetails(_requestid, _itemid, _number);
            }
            else
            {
                oResourceRequest.DeleteDetails(_requestid, _itemid, _number, _resourceid);
            }


            int     intParent = oResourceRequest.GetWorkflowParent(_resourceid);
            DataSet dsWF      = oResourceRequest.GetWorkflowsParent(intParent);

            if (boolJoined)
            {
                foreach (DataRow drWF in dsWF.Tables[0].Rows)
                {
                    oResourceRequest.DeleteWorkflowHours(Int32.Parse(drWF["id"].ToString()));
                    oResourceRequest.UpdateWorkflowUsed(Int32.Parse(drWF["id"].ToString()), 0.00);
                }
            }
            else
            {
                oResourceRequest.DeleteWorkflowHours(_resourceid);
                oResourceRequest.UpdateWorkflowUsed(_resourceid, 0.00);
            }
            double dblQuantity = double.Parse(oResourceRequest.GetWorkflow(_resourceid, "devices"));

            foreach (string strForm in oForm.Form)
            {
                string strNameID = strForm;
                strNameID = strNameID.ToUpper();
                if (strForm.StartsWith("hdnDetail_") == true)
                {
                    string strValue  = oForm.Form[strForm];
                    int    intDetail = Int32.Parse(strForm.Substring(strForm.IndexOf("hdnDetail_") + 10));
                    oResourceRequest.AddDetails(_requestid, _itemid, _number, (boolJoined ? 0 : _resourceid), intDetail, Int32.Parse(strValue));
                    if (Int32.Parse(strValue) == 1)
                    {
                        // selected - the following function will update all JOINED values
                        oResourceRequest.UpdateWorkflowHours(_resourceid, (double.Parse(Get(intDetail, "hours")) * dblQuantity));
                    }
                }
            }
        }