//生成文号
        protected void btnSetNo_Click(object sender, EventArgs e)
        {
            try
            {
                LetterNum numf = new LetterNum();

                txtOurRef.Text = numf.GetNo(txtCompanyID.Text, drpHanJian.SelectedValue);
            }
            catch (Exception ex)
            {
                //JScript.ShowMsgBox(Page, MsgType.VbInformation, ex.Message);
                JScript.Alert(ex.Message, false);
            }
        }
        protected void btnCheck_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtOurRef.Text != "")
                {
                    string sNum = "";
                    //检查 因为单位编码CANH是4位 从第5位开始截取6个字符 为发文流水号
                    try
                    {
                        sNum = txtOurRef.Text.Substring(4, 6);
                    }
                    catch
                    {
                        //JScript.ShowMsgBox(Page, MsgType.VbInformation, "函件发文号必须为CANH+6位流水号+对方单位编码!");
                        JScript.Alert("函件发文号必须为CANH+6位流水号+对方单位编码!", false);
                        return;
                    }
                    LetterNum num = new LetterNum();

                    string sMessage = "";
                    bool   b        = num.CheckSameNo(sNum, txtCompanyID.Text, drpHanJian.SelectedValue, ref sMessage);
                    if (b)
                    {
                        //JScript.ShowMsgBox(Page, MsgType.VbInformation, "发文号重复!");
                        JScript.Alert("发文号重复!", false);
                    }
                    else
                    {
                        //JScript.ShowMsgBox(Page, MsgType.VbInformation, "此发文号可以使用!" + sMessage);
                        JScript.Alert("此发文号可以使用!" + sMessage, false);
                    }
                }
                else
                {
                    //JScript.ShowMsgBox(Page, MsgType.VbInformation, "请先生成发文号!");
                    JScript.Alert("请先生成发文号!", false);
                }
            }
            catch (Exception ex)
            {
                //JScript.ShowMsgBox(Page, MsgType.VbInformation, ex.Message);
                JScript.Alert(ex.Message, false);
            }
        }
        protected void btnCheck_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtOurRef.Text != "")
                {
                    string sNum = "";
                    //检查 因为单位编码CANH是4位 从第5位开始截取6个字符 为发文流水号
                    try
                    {
                        sNum = txtOurRef.Text.Substring(4, 6);
                    }
                    catch
                    {
                        //JScript.ShowMsgBox(Page, MsgType.VbInformation, "函件发文号必须为CANH+6位流水号+对方单位编码!");
                        JScript.Alert("函件发文号必须为CANH+6位流水号+对方单位编码!", false);
                        return;
                    }
                    LetterNum num = new LetterNum();

                    string sMessage = "";
                    bool b = num.CheckSameNo(sNum, txtCompanyID.Text, drpHanJian.SelectedValue, ref sMessage);
                    if (b)
                    {
                        //JScript.ShowMsgBox(Page, MsgType.VbInformation, "发文号重复!");
                        JScript.Alert("发文号重复!", false);
                    }
                    else
                    {
                        //JScript.ShowMsgBox(Page, MsgType.VbInformation, "此发文号可以使用!" + sMessage);
                        JScript.Alert("此发文号可以使用!" + sMessage, false);
                    }
                }
                else
                {
                    //JScript.ShowMsgBox(Page, MsgType.VbInformation, "请先生成发文号!");
                    JScript.Alert("请先生成发文号!", false);
                }
            }
            catch (Exception ex)
            {
                //JScript.ShowMsgBox(Page, MsgType.VbInformation, ex.Message);
                JScript.Alert(ex.Message, false);
            }
        }
        protected void SubmitEvents(object sender, EventArgs e)
        {
            try
            {
                if (IsPreview == false)
                {
                    string strActionName = ((Button)sender).Text.Trim();
                    base.SubAction = strActionName;

                    if (strActionName == ProcessConstString.SubmitAction.ACTION_SAVE_DRAFT) //保存
                    {
                        EntityLetterSend entity = ControlToEntity(true) as EntityLetterSend;
                        entity.SubmitAction = strActionName;
                        base.FormSubmit(true, strActionName, null, entity as EntityBase);
                    }
                    else
                    {
                        EntityLetterSend entity = ControlToEntity(false) as EntityLetterSend;
                        entity.SubmitAction = strActionName;
                        if (CheckData(entity) == false)
                        {
                            return;
                        }

                        if (strActionName == ProcessConstString.SubmitAction.ACTION_CANCEL)
                        {
                            base.FormCancel(entity as EntityBase);
                        }
                        else
                        {
                            if (base.StepName == ProcessConstString.StepName.LetterSend.函件分发)
                            {
                                if (base.SubAction == "完成")
                                {
                                    //新增文号
                                    LetterNum lnum = new LetterNum();
                                    lnum.UpdateNo(txtOurRef.Text, txtCompanyID.Text, drpHanJian.SelectedValue);
                                    entity.ReceiveUserID = entity.ReceiveUserID;
                                }
                            }
                            Hashtable ht = EntityLetterSend.GetProcNameValue(base.StepName, strActionName, entity);//ap属性
                            base.FormSubmit(false, strActionName, ht, entity as EntityBase);

                            if (base.StepName == ProcessConstString.StepName.LetterSend.函件分发)
                            {
                                if (base.SubAction == "完成")
                                {
                                    base.Circulate(entity.ccDeptIDs, "1", "", GetCYNames(entity), "2", false, "", true);
                                }
                            }
                        }
                    }
                }
                else
                {
                    string strActionName = ((Button)sender).Text.Trim();
                    base.SubAction = strActionName;

                    EntityLetterSend entity = ControlToEntity(false) as EntityLetterSend;

                    if (strActionName == "追加分发")
                    {
                        base.Circulate(entity.ccDeptIDs, "1", "", GetCYNames(entity), "2", false, "", true);
                    }
                    else if (strActionName == "二次分发")
                    {
                        base.WorkItemID = Guid.NewGuid().ToString("N");
                        base.StepName   = "二次分发";
                        base.SaveNewEntity(strActionName, entity);
                        base.Circulate(entity.ccDeptIDs, "1", "", GetCYNames(entity), "4", true, "", true);
                    }
                }
            }
            catch (Exception ex)
            {
                //JScript.ShowMsgBox(Page, MsgType.VbCritical, ex.Message);
                JScript.Alert(ex.Message, false);
                return;
            }
        }
        protected void SubmitEvents(object sender, EventArgs e)
        {
            try
            {
                if (IsPreview == false)
                {
                    string strActionName = ((Button)sender).Text.Trim();
                    base.SubAction = strActionName;

                    if (strActionName == ProcessConstString.SubmitAction.ACTION_SAVE_DRAFT) //保存
                    {
                        EntityLetterSend entity = ControlToEntity(true) as EntityLetterSend;
                        entity.SubmitAction = strActionName;
                        base.FormSubmit(true, strActionName, null, entity as EntityBase);
                    }
                    else
                    {
                        EntityLetterSend entity = ControlToEntity(false) as EntityLetterSend;
                        entity.SubmitAction = strActionName;
                        if (CheckData(entity) == false)
                        {
                            return;
                        }

                        if (strActionName == ProcessConstString.SubmitAction.ACTION_CANCEL)
                        {
                            base.FormCancel(entity as EntityBase);
                        }
                        else
                        {
                            if (base.StepName == ProcessConstString.StepName.LetterSend.函件分发)
                            {
                                if (base.SubAction == "完成")
                                {
                                    //新增文号
                                    LetterNum lnum = new LetterNum();
                                    lnum.UpdateNo(txtOurRef.Text, txtCompanyID.Text, drpHanJian.SelectedValue);
                                    entity.ReceiveUserID = entity.ReceiveUserID;
                                }
                            }
                            Hashtable ht = EntityLetterSend.GetProcNameValue(base.StepName, strActionName, entity);//ap属性
                            base.FormSubmit(false, strActionName, ht, entity as EntityBase);

                            if (base.StepName == ProcessConstString.StepName.LetterSend.函件分发)
                            {
                                if (base.SubAction == "完成")
                                {
                                    base.Circulate(entity.ccDeptIDs, "1", "", GetCYNames(entity), "2", false, "", true);
                                }
                            }
                        }
                    }
                }
                else
                {
                    string strActionName = ((Button)sender).Text.Trim();
                    base.SubAction = strActionName;

                    EntityLetterSend entity = ControlToEntity(false) as EntityLetterSend;

                    if (strActionName == "追加分发")
                    {
                        base.Circulate(entity.ccDeptIDs, "1", "", GetCYNames(entity), "2", false, "", true);
                    }
                    else if (strActionName == "二次分发")
                    {
                        base.WorkItemID = Guid.NewGuid().ToString("N");
                        base.StepName = "二次分发";
                        base.SaveNewEntity(strActionName, entity);
                        base.Circulate(entity.ccDeptIDs, "1", "", GetCYNames(entity), "4", true, "", true);
                    }
                }
            }
            catch (Exception ex)
            {
                //JScript.ShowMsgBox(Page, MsgType.VbCritical, ex.Message);
                JScript.Alert(ex.Message, false);
                return;
            }
        }
        //生成文号
        protected void btnSetNo_Click(object sender, EventArgs e)
        {
            try
            {
                LetterNum numf = new LetterNum();

                txtOurRef.Text = numf.GetNo(txtCompanyID.Text, drpHanJian.SelectedValue);
            }
            catch (Exception ex)
            {
                //JScript.ShowMsgBox(Page, MsgType.VbInformation, ex.Message);
                JScript.Alert(ex.Message, false);
            }
        }