예제 #1
0
        /// <summary>
        /// 提交单据
        /// </summary>
        /// <param name="salesOrder">单据信息数据集</param>
        /// <param name="listPartInfo">零件明细信息</param>
        /// <param name="listReviewInfo">评审信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool InsertBill(YX_SalesOrder salesOrder, DataTable listPartInfo, DataTable listReviewInfo, out string error)
        {
            error = null;
            DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

            try
            {
                dataContext.Connection.Open();
                dataContext.Transaction = dataContext.Connection.BeginTransaction();

                var varData = from a in dataContext.YX_SalesOrder
                              where a.BillNo == salesOrder.BillNo
                              select a;

                if (varData.Count() == 1)
                {
                    if (!DeletePartList(dataContext, salesOrder.BillNo, out error)
                        && !DeleteReviewList(dataContext, salesOrder.BillNo, out error))
                    {
                        return false;
                    }

                    if (!DeleteReviewList(dataContext, salesOrder.BillNo, out error))
                    {
                        return false;
                    }

                    dataContext.YX_SalesOrder.DeleteAllOnSubmit(varData);
                    dataContext.SubmitChanges();
                }

                dataContext.YX_SalesOrder.InsertOnSubmit(salesOrder);
                dataContext.SubmitChanges();

                if (!InsertPartList(dataContext, salesOrder.BillNo, listPartInfo, out error))
                {
                    throw new Exception(error);
                }

                if (!InsertReviewList(dataContext, salesOrder.BillNo, listReviewInfo, out error))
                {
                    throw new Exception(error);
                }

                dataContext.SubmitChanges();

                dataContext.Transaction.Commit();
                return true;
            }
            catch (Exception ex)
            {
                error = ex.Message;
                dataContext.Transaction.Rollback();
                return false;
            }
        }
        private void 提交订单评审ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!CheckControl())
            {
                return;
            }

            YX_SalesOrder salesOrder = new YX_SalesOrder();

            if (txtBillNo.Text == "系统自动生成")
            {
                salesOrder.BillNo = m_salesOrderServer.GetNextBillID();
            }
            else
            {
                salesOrder.BillNo = txtBillNo.Text;
            }

            salesOrder.Applicant     = BasicInfo.LoginID;
            salesOrder.ApplicantDate = ServerTime.Time;
            salesOrder.ClientCode    = txtClient.Tag.ToString();
            salesOrder.ContractName  = txtContractName.Text;
            salesOrder.DealRequire   = txtDealRequire.Text;
            salesOrder.Month         = Convert.ToInt32(numMonth.Value);
            salesOrder.Year          = Convert.ToInt32(numYear.Value);
            salesOrder.ReviewType    = txtReviewType.Text;
            salesOrder.Status        = SalesOrderStatus.等待审核.ToString();

            DataTable partListDt = (DataTable)dgvPartList.DataSource;

            DataTable reviewDt = new DataTable();

            reviewDt.Columns.Add("DeptCode");

            for (int i = 0; i < dgvReview.Rows.Count; i++)
            {
                DataRow dr = reviewDt.NewRow();

                dr["DeptCode"] = dgvReview.Rows[i].Cells["部门编码"].Value.ToString();

                reviewDt.Rows.Add(dr);
            }

            if (!m_salesOrderServer.InsertBill(salesOrder, partListDt, reviewDt, out m_error))
            {
                MessageDialog.ShowPromptMessage(m_error);
                return;
            }

            m_billMessageServer.SendNewFlowMessage(salesOrder.BillNo, string.Format("{0}号销售订单评审,等待主管审核", salesOrder.BillNo),
                                                   BillFlowMessage_ReceivedUserType.角色, m_billMessageServer.GetSuperior(CE_RoleStyleType.级领导, BasicInfo.LoginID));

            this.Close();
        }
        private void 回退部门评审ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (txtStatus.Text == SalesOrderStatus.等待确认评审.ToString())
            {
                string deptCode = dgvReview.Rows[0].Cells["部门"].Value.ToString();

                YX_SalesOrder salesOrder = new YX_SalesOrder();

                salesOrder.BillNo = txtBillNo.Text;
                salesOrder.Status = SalesOrderStatus.等待评审.ToString();

                DataTable reviewDt = new DataTable();

                reviewDt.Columns.Add("DeptCode");
                reviewDt.Columns.Add("Opinion");
                reviewDt.Columns.Add("Confirm");
                reviewDt.Columns.Add("ConfirmDate");

                for (int i = 0; i < dgvReview.Rows.Count; i++)
                {
                    DataRow dr = reviewDt.NewRow();

                    dr["DeptCode"]    = dgvReview.Rows[i].Cells["部门编码"].Value.ToString();
                    dr["Opinion"]     = dgvReview.Rows[i].Cells["评审意见"].Value.ToString();
                    dr["Confirm"]     = dgvReview.Rows[i].Cells["评审确认人"].Value.ToString();
                    dr["ConfirmDate"] = dgvReview.Rows[i].Cells["评审确认时间"].Value.ToString();

                    reviewDt.Rows.Add(dr);
                }

                if (!m_salesOrderServer.OperationInfo(salesOrder, (DataTable)dgvPartList.DataSource, reviewDt,
                                                      "", "", salesOrder.Status, "主管审核", out m_error))
                {
                    MessageDialog.ShowPromptMessage(m_error);
                    return;
                }
                else
                {
                    MessageDialog.ShowPromptMessage("审核成功!");

                    string msg = string.Format("{0} 号销售订单评审,被" + BasicInfo.LoginName + "回退,请各部门重新评审!", txtBillNo.Text);
                    m_billMessageServer.PassFlowMessage(txtBillNo.Text, msg,
                                                        BillFlowMessage_ReceivedUserType.角色, m_billMessageServer.GetDeptPrincipalRoleName(deptCode).ToList());

                    this.Close();
                }
            }
            else
            {
                MessageDialog.ShowPromptMessage("请确认单据状态!");
            }
        }
        private void 审核toolStripButton_Click(object sender, EventArgs e)
        {
            if (txtStatus.Text == SalesOrderStatus.等待审核.ToString())
            {
                string deptCode = dgvReview.Rows[0].Cells["部门"].Value.ToString();

                YX_SalesOrder salesOrder = new YX_SalesOrder();

                salesOrder.BillNo    = txtBillNo.Text;
                salesOrder.Status    = SalesOrderStatus.等待评审.ToString();
                salesOrder.Auditer   = BasicInfo.LoginID;
                salesOrder.AuditDate = ServerTime.Time;

                DataTable reviewDt = new DataTable();

                reviewDt.Columns.Add("DeptCode");

                for (int i = 0; i < dgvReview.Rows.Count; i++)
                {
                    DataRow dr = reviewDt.NewRow();

                    dr["DeptCode"] = dgvReview.Rows[i].Cells["部门编码"].Value.ToString();

                    reviewDt.Rows.Add(dr);
                }

                if (!m_salesOrderServer.OperationInfo(salesOrder, null, null, "", "", salesOrder.Status, "主管审核", out m_error))
                {
                    MessageDialog.ShowPromptMessage(m_error);
                    return;
                }
                else
                {
                    MessageDialog.ShowPromptMessage("审核成功!");

                    string msg = string.Format("{0} 号销售订单评审,请评审部门评审", txtBillNo.Text);
                    m_billMessageServer.PassFlowMessage(txtBillNo.Text, msg,
                                                        BillFlowMessage_ReceivedUserType.角色, m_billMessageServer.GetDeptPrincipalRoleName(deptCode).ToList());

                    this.Close();
                }
            }
            else
            {
                MessageDialog.ShowPromptMessage("请确认单据状态!");
            }
        }
        private void 结果toolStripButton_Click(object sender, EventArgs e)
        {
            if (txtStatus.Text == SalesOrderStatus.等待评审结果.ToString())
            {
                if (txtReviewResult.Text.Trim() == "")
                {
                    MessageDialog.ShowPromptMessage("请填写评审结果!");
                    return;
                }

                YX_SalesOrder salesOrder = new YX_SalesOrder();

                salesOrder.BillNo       = txtBillNo.Text;
                salesOrder.Status       = SalesOrderStatus.等待确认生效.ToString();
                salesOrder.ResultPerson = BasicInfo.LoginID;
                salesOrder.ResultDate   = ServerTime.Time;
                salesOrder.ReviewResult = txtReviewResult.Text;

                DataTable partDt = (DataTable)dgvPartList.DataSource;

                if (!m_salesOrderServer.OperationInfo(salesOrder, partDt, null, "", "", salesOrder.Status, "评审结果", out m_error))
                {
                    MessageDialog.ShowPromptMessage(m_error);
                    return;
                }
                else
                {
                    List <string> noticeUser = new List <string>();

                    noticeUser.Add(txtApplicant.Tag.ToString());

                    string msg = string.Format("{0} 号销售订单评审等待订单生效生成出库单", txtBillNo.Text);
                    m_billMessageServer.PassFlowMessage(m_billNo, msg,
                                                        BillFlowMessage_ReceivedUserType.用户, txtApplicant.Tag.ToString());

                    this.Close();
                }
            }
            else
            {
                MessageDialog.ShowPromptMessage("请确认单据状态!");
            }
        }
        private void 确认评审ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (txtStatus.Text == SalesOrderStatus.等待确认评审.ToString())
            {
                string deptCode = dgvReview.Rows[0].Cells["部门"].Value.ToString();


                YX_SalesOrder salesOrder = new YX_SalesOrder();

                salesOrder.BillNo       = txtBillNo.Text;
                salesOrder.Status       = SalesOrderStatus.等待评审结果.ToString();
                salesOrder.ResultPerson = BasicInfo.LoginID;
                salesOrder.ResultDate   = ServerTime.Time;
                salesOrder.ReviewResult = txtReviewResult.Text;

                DataTable partDt = (DataTable)dgvPartList.DataSource;

                if (!m_salesOrderServer.OperationInfo(salesOrder, partDt, null, "", "", salesOrder.Status, "确认评审", out m_error))
                {
                    MessageDialog.ShowPromptMessage(m_error);
                    return;
                }
                else
                {
                    List <string> noticeUser = new List <string>();

                    noticeUser.Add(txtApplicant.Tag.ToString());

                    string msg = string.Format("{0} 号销售订单评审,等待评审结果", txtBillNo.Text);
                    m_billMessageServer.PassFlowMessage(m_billNo, msg,
                                                        BillFlowMessage_ReceivedUserType.角色, CE_RoleEnum.营销负责人.ToString());

                    this.Close();
                }
            }
            else
            {
                MessageDialog.ShowPromptMessage("请确认单据状态!");
            }
        }
예제 #7
0
        /// <summary>
        /// 操作业务
        /// </summary>
        /// <param name="salesOrder">单据信息数据集</param>
        /// <param name="listPartInfo">零件明细信息</param>
        /// <param name="listReviewInfo">评审部门信息</param>
        /// <param name="deptCode">部门编码</param>
        /// <param name="opinion">部门评审意见</param>
        /// <param name="status">单据状态</param>
        /// <param name="type">操作类型(主管审核、部门评审、评审结果)</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool OperationInfo(YX_SalesOrder salesOrder, DataTable listPartInfo, DataTable listReviewInfo,
                                  string deptCode, string opinion, string status, string type, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                var varData = from a in dataContext.YX_SalesOrder
                              where a.BillNo == salesOrder.BillNo
                              select a;

                var resultReview = from a in dataContext.YX_SalesOrderReview
                                   where a.BillNo == salesOrder.BillNo && a.DeptCode == deptCode
                                   select a;

                if (varData.Count() == 1)
                {
                    YX_SalesOrder lnqBill = varData.Single();

                    switch (type)
                    {
                        case "主管审核":
                            lnqBill.Status = status;

                            if (listReviewInfo != null && listReviewInfo.Rows.Count > 0)
                            {
                                if (resultReview.Count() > 0)
                                {
                                    foreach (YX_SalesOrderReview item in resultReview)
                                    {
                                        YX_SalesOrderReviewHistory history = new YX_SalesOrderReviewHistory();

                                        history.BillNo = salesOrder.BillNo;
                                        history.Confirmation = UniversalFunction.GetPersonnelCode(item.Confirmation);
                                        history.ConfirmDate = Convert.ToDateTime(item.ConfirmDate);
                                        history.DeptCode = item.DeptCode;
                                        history.Opinion = item.Opinion;

                                        dataContext.YX_SalesOrderReviewHistory.InsertOnSubmit(history);
                                    }
                                }

                                if (!DeleteReviewList(dataContext, salesOrder.BillNo, out error))
                                {
                                    return false;
                                }

                                if (!InsertReviewList(dataContext, salesOrder.BillNo, listReviewInfo, out error))
                                {
                                    return false;
                                }

                                if (!DeletePartList(dataContext, salesOrder.BillNo, out error)
                                    && !DeleteReviewList(dataContext, salesOrder.BillNo, out error))
                                {
                                    return false;
                                }

                                if (!InsertPartList(dataContext, salesOrder.BillNo, listPartInfo, out error))
                                {
                                    throw new Exception(error);
                                }
                            }
                            else
                            {
                                lnqBill.Auditer = salesOrder.Auditer;
                                lnqBill.AuditDate = salesOrder.AuditDate;
                            }

                            break;

                        case "部门评审":

                            if (resultReview.Count() == 1)
                            {
                                YX_SalesOrderReview review = resultReview.Single();

                                review.Opinion = opinion;
                                review.Confirmation = BasicInfo.LoginID;
                                review.ConfirmDate = ServerTime.Time;

                                lnqBill.Status = status;
                            }
                            else
                            {
                                error = "请确认评审部门!";
                                return false;
                            }
                            break;

                        case "确认评审":

                                lnqBill.Status = status;

                            break;

                        case "评审结果":
                            lnqBill.ResultPerson = salesOrder.ResultPerson;
                            lnqBill.ReviewResult = salesOrder.ReviewResult;
                            lnqBill.Status = status;
                            lnqBill.ResultDate = salesOrder.ResultDate;

                            if (!DeletePartList(dataContext, salesOrder.BillNo, out error))
                            {
                                return false;
                            }

                            if (!InsertPartList(dataContext, salesOrder.BillNo, listPartInfo, out error))
                            {
                                return false;
                            }

                            break;
                        default:
                            break;
                    }

                    dataContext.SubmitChanges();
                }
                else
                {
                    error = "数据不唯一";
                    return false;
                }

                return true;
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return false;
            }
        }
        private void 部门评审toolStripButton_Click(object sender, EventArgs e)
        {
            if (txtStatus.Text == SalesOrderStatus.等待评审.ToString())
            {
                bool flag = false;

                for (int i = 0; i < dgvReview.Rows.Count; i++)
                {
                    if (BasicInfo.DeptName == dgvReview.Rows[i].Cells["部门"].Value.ToString())
                    {
                        flag = true;

                        YX_SalesOrder salesOrder = new YX_SalesOrder();

                        salesOrder.BillNo = txtBillNo.Text;

                        if (i == dgvReview.Rows.Count - 1)
                        {
                            salesOrder.Status = SalesOrderStatus.等待确认评审.ToString();
                        }
                        else
                        {
                            salesOrder.Status = SalesOrderStatus.等待评审.ToString();
                        }

                        if (!m_salesOrderServer.OperationInfo(salesOrder, null, null, BasicInfo.DeptCode,
                                                              dgvReview.Rows[i].Cells["评审意见"].Value.ToString(), salesOrder.Status, "部门评审", out m_error))
                        {
                            MessageDialog.ShowPromptMessage(m_error);
                        }
                        else
                        {
                            MessageDialog.ShowPromptMessage("评审成功!");

                            if (salesOrder.Status == SalesOrderStatus.等待评审.ToString())
                            {
                                string msg = string.Format("{0} 号销售订单评审,请部门评审", m_billNo);
                                m_billMessageServer.PassFlowMessage(m_billNo, msg,
                                                                    BillFlowMessage_ReceivedUserType.角色, m_billMessageServer.GetDeptPrincipalRoleName(
                                                                        dgvReview.Rows[i + 1].Cells["部门"].Value.ToString()).ToList());
                            }
                            else
                            {
                                string msg = string.Format("{0} 号销售订单评审,请营销确认评审意见", m_billNo);
                                m_billMessageServer.PassFlowMessage(m_billNo, msg,
                                                                    BillFlowMessage_ReceivedUserType.用户, txtApplicant.Tag.ToString());
                            }

                            this.Close();
                        }
                    }
                }

                if (!flag)
                {
                    MessageDialog.ShowPromptMessage("请确认评审部门!");
                }
            }
            else
            {
                MessageDialog.ShowPromptMessage("请确认单据状态!");
            }
        }
예제 #9
0
        /// <summary>
        /// 操作业务
        /// </summary>
        /// <param name="salesOrder">单据信息数据集</param>
        /// <param name="listPartInfo">零件明细信息</param>
        /// <param name="listReviewInfo">评审部门信息</param>
        /// <param name="deptCode">部门编码</param>
        /// <param name="opinion">部门评审意见</param>
        /// <param name="status">单据状态</param>
        /// <param name="type">操作类型(主管审核、部门评审、评审结果)</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool OperationInfo(YX_SalesOrder salesOrder, DataTable listPartInfo, DataTable listReviewInfo,
                                  string deptCode, string opinion, string status, string type, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                var varData = from a in dataContext.YX_SalesOrder
                              where a.BillNo == salesOrder.BillNo
                              select a;

                if (varData.Count() == 1)
                {
                    YX_SalesOrder lnqBill = varData.Single();

                    switch (type)
                    {
                    case "主管审核":
                        lnqBill.Status    = status;
                        lnqBill.Auditer   = salesOrder.Auditer;
                        lnqBill.AuditDate = salesOrder.AuditDate;

                        if (!DeleteReviewList(dataContext, salesOrder.BillNo, out error))
                        {
                            return(false);
                        }

                        if (!InsertReviewList(dataContext, salesOrder.BillNo, listReviewInfo, out error))
                        {
                            return(false);
                        }

                        break;

                    case "部门评审":
                        var resultReview = from a in dataContext.YX_SalesOrderReview
                                           where a.BillNo == salesOrder.BillNo && a.DeptCode == deptCode
                                           select a;

                        if (resultReview.Count() == 1)
                        {
                            YX_SalesOrderReview review = resultReview.Single();

                            review.Opinion      = opinion;
                            review.Confirmation = BasicInfo.LoginID;
                            review.ConfirmDate  = ServerTime.Time;

                            lnqBill.Status = status;
                        }
                        else
                        {
                            error = "请确认评审部门!";
                            return(false);
                        }
                        break;

                    case "确认评审":

                        lnqBill.Status = status;

                        break;

                    case "评审结果":
                        lnqBill.ResultPerson = salesOrder.ResultPerson;
                        lnqBill.ReviewResult = salesOrder.ReviewResult;
                        lnqBill.Status       = status;
                        lnqBill.ResultDate   = salesOrder.ResultDate;

                        if (!DeletePartList(dataContext, salesOrder.BillNo, out error))
                        {
                            return(false);
                        }

                        if (!InsertPartList(dataContext, salesOrder.BillNo, listPartInfo, out error))
                        {
                            return(false);
                        }

                        break;

                    default:
                        break;
                    }

                    dataContext.SubmitChanges();
                }
                else
                {
                    error = "数据不唯一";
                    return(false);
                }

                dataContext.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }