コード例 #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (Session[WebConstants.Session.USER_CO_ID] != null && Session[WebConstants.Session.DEPT_ID] != null)
        {
            int loggedInUserCoId = (int)Session[WebConstants.Session.USER_CO_ID];
            int deptId = (int)Session[WebConstants.Session.DEPT_ID];

            DepartmentOrderDocTableAdapters.DepartmentOrderDocTableAdapter tableAdapter = new DepartmentOrderDocTableAdapters.DepartmentOrderDocTableAdapter();
            foreach (RepeaterItem repeaterItem in rptDocs.Items)
            {
                CheckBoxList cbDocs = repeaterItem.FindControl("cbDocs") as CheckBoxList;
                foreach (ListItem listItem in cbDocs.Items)
                {
                    if (listItem.Selected)
                    {
                        tableAdapter.Insert(int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID]), int.Parse(listItem.Value), deptId, loggedInUserCoId, false);
                    }
                }
            }
            gvDocs.DataBind();
            BindRepeater();
        }
    }
コード例 #2
0
    protected void btnCopy_Click(object sender, EventArgs e)
    {
        DepartmentOrder.DepartmentOrderRowRow order = DatabaseUtility.GetDepartmentOrder(int.Parse(hfSourceOrderId.Value));
        if (order != null)
        {
            Nullable<bool> flgDocToClient = null;
            Nullable<int> estWork = null;
            Nullable<bool> multiEmerExits = null;
            Nullable<bool> multiAssemPts = null;
            Nullable<bool> flgCancelled = null;
            Nullable<DateTime> dateCancelled = null;
            Nullable<int> estNumOfOperatives = null;
            if (order.Isflg_order_doc_to_clientNull() == false) flgDocToClient = order.flg_order_doc_to_client;
            if (order.Isorder_est_of_worksNull() == false) estWork = order.order_est_of_works;
            if (order.Isflg_multi_emer_exitsNull() == false) multiEmerExits = order.flg_multi_emer_exits;
            if (order.Isflg_multi_assem_pointsNull() == false) multiAssemPts = order.flg_multi_assem_points;
            if (order.Isflg_cancelledNull() == false) flgCancelled = order.flg_cancelled;
            if (order.Isdate_cancelledNull() == false) dateCancelled = order.date_cancelled;
            if (order.Isest_num_of_operativesNull() == false) estNumOfOperatives = order.est_num_of_operatives;

            DepartmentOrderTableAdapters.DepartmentOrderRowTableAdapter da = new DepartmentOrderTableAdapters.DepartmentOrderRowTableAdapter();
            IEnumerator iEnum = da.InsertAndReturn(false, order.dept_id, order.co_id, order.order_ref, order.order_client_ref, order.order_sms,
                DateTime.Now, estWork, DateTime.Now.AddYears(1), flgDocToClient, tbAddressNo.Text,tbAddress1.Text,tbAddress2.Text,tbAddress3.Text,
                tbAddress4.Text,tbAddress5.Text,tbPostalCode.Text,getFullAddress(),(order.Isorder_descNull()) ? null : order.order_desc,
                multiEmerExits, multiAssemPts, flgCancelled, dateCancelled,(order.Isdesc_of_workNull()) ? null : order.desc_of_work,estNumOfOperatives,
                (order.Isrisk_takingNull())?null:order.risk_taking,loggedInUserId, DateTime.Now, loggedInUserId, DateTime.Now).GetEnumerator();
            if (iEnum.MoveNext())
            {
                DepartmentOrder.DepartmentOrderRowRow newOrder = (DepartmentOrder.DepartmentOrderRowRow)iEnum.Current;

                //copy persons
                DepartmentOrderPersonTableAdapters.DepartmentOrderPersonEntityTableAdapter personTA = new DepartmentOrderPersonTableAdapters.DepartmentOrderPersonEntityTableAdapter();
                IEnumerator iEPerson = personTA.GetAllOrderPersonsByOrderId(order.dept_id, order.co_id, order.sequence).GetEnumerator();

                while (iEPerson.MoveNext())
                {
                    DepartmentOrderPerson.DepartmentOrderPersonEntityRow personDR = (DepartmentOrderPerson.DepartmentOrderPersonEntityRow)iEPerson.Current;
                    Nullable<bool> flgSupervisor = null;
                    Nullable<bool> flgFirstAider = null;
                    Nullable<bool> flgFireWarden = null;
                    string personName = (personDR.Isname_descNull()) ? null : personDR.name_desc;
                    if (personDR.Issuperrvisor_checkNull() == false) flgSupervisor = Convert.ToBoolean(personDR.superrvisor_check);
                    if (personDR.Isfirstaiderr_checkNull() == false) flgFirstAider = Convert.ToBoolean(personDR.firstaiderr_check);
                    if (personDR.Isfirewardenn_checkNull() == false) flgFireWarden = Convert.ToBoolean(personDR.firewardenn_check);

                    personTA.Insert(personDR.dept_id, personDR.co_id, newOrder.sequence, personName, loggedInUserId, flgSupervisor, flgFirstAider, flgFireWarden,false);
                }

                //copy hazards
                DepartmentOrderDetailTableAdapters.DepartmentOrderHazardTableAdapter hazaradTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderHazardTableAdapter();
                IEnumerator iEHazard = hazaradTA.GetAllHazards(order.dept_id, order.co_id, order.sequence).GetEnumerator();
                while (iEHazard.MoveNext())
                {
                    DepartmentOrderDetail.DepartmentOrderHazardRow hazardDR = (DepartmentOrderDetail.DepartmentOrderHazardRow)iEHazard.Current;
                    hazaradTA.Insert(order.dept_id, order.co_id, newOrder.sequence, hazardDR.hazard_desc, loggedInUserId);
                }

                //copy sequence of work
                DepartmentOrderDetailTableAdapters.DepartmentOrderWorkTableAdapter workTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderWorkTableAdapter();
                IEnumerator iEWork = workTA.GetAllWorks(order.dept_id, order.co_id, order.sequence).GetEnumerator();
                while (iEWork.MoveNext())
                {
                    DepartmentOrderDetail.DepartmentOrderWorkRow workDR = (DepartmentOrderDetail.DepartmentOrderWorkRow)iEWork.Current;
                    workTA.Insert(order.dept_id, order.co_id, newOrder.sequence, workDR.work_desc, loggedInUserId);
                }

                //copy plats and tools
                DepartmentOrderDetailTableAdapters.DepartmentOrderToolTableAdapter toolTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderToolTableAdapter();
                IEnumerator iETool = toolTA.GetAllDepartmentTool(order.dept_id, order.co_id, order.sequence).GetEnumerator();
                while (iETool.MoveNext())
                {
                    DepartmentOrderDetail.DepartmentOrderToolRow toolDR = (DepartmentOrderDetail.DepartmentOrderToolRow)iETool.Current;
                    toolTA.Insert(order.dept_id, order.co_id, newOrder.sequence, toolDR.tool_desc, loggedInUserId);
                }

                //copy PPE
                DepartmentOrderDetailTableAdapters.DepartmentOrderPPETableAdapter ppeTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderPPETableAdapter();
                IEnumerator iEPPE = ppeTA.GetAllPPE(order.dept_id, order.co_id, order.sequence).GetEnumerator();
                while (iEPPE.MoveNext())
                {
                    DepartmentOrderDetail.DepartmentOrderPPERow ppeDR = (DepartmentOrderDetail.DepartmentOrderPPERow)iEPPE.Current;
                    ppeTA.Insert(order.dept_id, order.co_id, newOrder.sequence, ppeDR.ppe_desc, loggedInUserId);
                }

                //copy Emergency
                DepartmentOrderDetailTableAdapters.DepartmentOrderEmergencyExitTableAdapter emergencyTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderEmergencyExitTableAdapter();
                IEnumerator iEEmergency = emergencyTA.GetAllEmergencyExits(order.dept_id, order.co_id, order.sequence).GetEnumerator();
                while (iEEmergency.MoveNext())
                {
                    DepartmentOrderDetail.DepartmentOrderEmergencyExitRow emergencyDR = (DepartmentOrderDetail.DepartmentOrderEmergencyExitRow)iEEmergency.Current;
                    emergencyTA.Insert(order.dept_id, order.co_id, newOrder.sequence, emergencyDR.emer_exit_title, null, loggedInUserId);
                }

                //copy Requirements
                DepartmentOrderDetailTableAdapters.DepartmentOrderRequirementTableAdapter requirementTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderRequirementTableAdapter();
                IEnumerator iERequirements = requirementTA.GetAllRequirements(order.dept_id,order.co_id,order.sequence).GetEnumerator();
                while(iERequirements.MoveNext())
                {
                    DepartmentOrderDetail.DepartmentOrderRequirementRow requirementDR = (DepartmentOrderDetail.DepartmentOrderRequirementRow)iERequirements.Current;
                    requirementTA.Insert(order.dept_id,order.co_id,newOrder.sequence,requirementDR.requirement_header,null,loggedInUserId);
                }

                //copy Aspects
                DepartmentOrderDetailTableAdapters.DepartmentOrderKeyAspectsTableAdapter aspectsTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderKeyAspectsTableAdapter();
                IEnumerator iEAspects = aspectsTA.GetAllKeyAspects(order.dept_id,order.co_id,order.sequence).GetEnumerator();
                while(iEAspects.MoveNext())
                {
                    DepartmentOrderDetail.DepartmentOrderKeyAspectsRow aspectsDR = (DepartmentOrderDetail.DepartmentOrderKeyAspectsRow)iEAspects.Current;
                    aspectsTA.Insert(order.dept_id,order.co_id,newOrder.sequence,aspectsDR.key_aspect_header,null,loggedInUserId);
                }

                //copy Docs

                DepartmentOrderDocTableAdapters.DepartmentOrderDocTableAdapter docTA = new DepartmentOrderDocTableAdapters.DepartmentOrderDocTableAdapter();
                IEnumerator iEDocs = docTA.GetAllDocs(order.co_id,order.dept_id,order.sequence).GetEnumerator();
                while(iEDocs.MoveNext())
                {
                    DepartmentOrderDoc.DepartmentOrderDocEntityRow docDR = (DepartmentOrderDoc.DepartmentOrderDocEntityRow)iEDocs.Current;
                    docTA.Insert(newOrder.sequence,docDR.doc_id,order.dept_id,order.co_id,false);
                }
            }
        }

        GridView1.DataBind();
    }
コード例 #3
0
    private void GenerateFolder()
    {
        hlDoc.Visible = false;
        Image4.Visible = false;
        Image5.Visible = false;
        List<DocumentType> docTypes = new List<DocumentType>();
        for (int i=0;i<rptDocTypes.Items.Count;i++)
        {
            RepeaterItem item = rptDocTypes.Items[i];
            CheckBox cb = (CheckBox)item.FindControl("cbDocType");
            if (cb.Checked == true)
            {
                DocumentType docType = new DocumentType();
                docType.DeptOrderId = int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID]);
                docType.Id = int.Parse(((HiddenField)item.FindControl("hfId")).Value);
                docType.Name = cb.Text;
                docType.Type = ((HiddenField)item.FindControl("hfFieldType")).Value;
                docType.GeneratorClass = ((HiddenField)item.FindControl("hfGeneratorClass")).Value;
                docType.CoId = int.Parse(((HiddenField)item.FindControl("hfCoId")).Value);
                docType.DeptId = int.Parse(((HiddenField)item.FindControl("hfDeptId")).Value);
                docType.IncludeBlankPage = cbBlankPage.Checked;
                HiddenField hfIsLandScape = (HiddenField)item.FindControl("hfIsLandScape");

                if (hfIsLandScape.Value.Length > 0 && bool.Parse(hfIsLandScape.Value) == true)
                    docType.IsLandScape = true;
                else
                    docType.IsLandScape = false;

                docType.Number = null;
                if (docType.Type.Equals("int"))
                {
                    NumericBox nb = (NumericBox)item.FindControl("nbNumOfPrints");
                    if (nb.Text.Length == 0)
                    {
                        SetErrorMessage("Number of Copies for " + docType.Name + " must be specified");
                        return;
                    }
                    else
                    {
                        docType.Number = int.Parse(nb.Text);
                    }
                }
                else if (docType.Type.Equals("detail"))
                {
                    DepartmentOrderDocTableAdapters.DepartmentOrderDocTableAdapter ta = new DepartmentOrderDocTableAdapters.DepartmentOrderDocTableAdapter();
                    IEnumerator ie = ta.GetDocsByType(loggedInUserCoId, (int)Session[WebConstants.Session.DEPT_ID], int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID]), docType.Id).GetEnumerator();
                    bool hasData = false;
                    while (ie.MoveNext())
                    {
                        DepartmentOrderDoc.DepartmentOrderDocEntityRow dr = (DepartmentOrderDoc.DepartmentOrderDocEntityRow)ie.Current;
                        docType.DocList.Add(dr.doc_id, dr.doc_name);
                        hasData = true;
                    }
                    if (hasData == false)
                    {
                        SetErrorMessage("Atleast one document against document type " + docType.Name + " must be selected");
                        return;
                    }
                }
                docTypes.Add(docType);
            }
            else
            {
                bool required = bool.Parse(((HiddenField)item.FindControl("hfRequired")).Value);
                if (required)
                {
                    SetErrorMessage("Document type " + cb.Text + " must be selected");
                    return;
                }
            }
        }
        if (docTypes.Count == 0)
        {
            SetErrorMessage(WebConstants.Messages.Error.SELECT_ATLEAST_ONE_DOCTYPE);
        }
        else
        {
            DepartmentOrderTableAdapters.DepartmentOrderRowTableAdapter ta = new DepartmentOrderTableAdapters.DepartmentOrderRowTableAdapter();
            ta.UpdateOrderDetails(null, DateTime.Parse(dtClient.Text), cbRegister.Checked, cbClosed.Checked, null, loggedInUserId, int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID]));
            FolderGenerator folderGenerator = new FolderGenerator(docTypes);
            if (folderGenerator.Generate())
            {
                string completePath = "~/Folders/" + folderGenerator.fileName;
                DepartmentOrderDetailTableAdapters.DepartmentOrderLogTableAdapter logTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderLogTableAdapter();
                logTA.Insert(int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID]), loggedInUserCoId, (int)Session[WebConstants.Session.DEPT_ID], loggedInUserId, DateTime.Now, completePath, false);
                ClientScript.RegisterStartupScript(this.GetType(), "redirect", "window.open(\"../Folders/" + folderGenerator.fileName + "\");",true);
                hlDoc.Visible = true;
                Image4.Visible = true;
                Image5.Visible = true;
                hlDoc.NavigateUrl = completePath;
            }
            else
            {
                SetErrorMessage(WebConstants.Messages.Error.DOC_NOT_GENERATED);
            }
        }
    }