Example #1
0
        //无事务,供事务调用
        private void AddAlertResBill2(string itemcode, string resCode, string ErrorCode)
        {
            try
            {
                BenQGuru.eMES.Domain.Alert.AlertResBill alert = new BenQGuru.eMES.Domain.Alert.AlertResBill();
                alert.AlertItem       = GetCheckItemCode();
                alert.AlertType       = this.rblAlertType.SelectedValue;
                alert.AlertMsg        = this.txtAlertMsg.Text;
                alert.Description     = this.txtDesc.Text;
                alert.ItemCode        = itemcode;                                                       //产品代码
                alert.ResourceCode    = resCode;                                                        //资源
                alert.ErrorGroup2Code = ErrorCode;                                                      //不良代码
                alert.Operator        = this.drpOperator.SelectedValue;
                alert.StartNum        = int.Parse(this.txtStartNum.Text == ""?"0":this.txtStartNum.Text);
                alert.MailNotify      = this.chbMailNotify.Checked?"Y":"N";
                alert.LowValue        = decimal.Parse(this.txtLow.Text);
                alert.UpValue         = decimal.Parse(this.txtUp.Text == ""?"0":this.txtUp.Text);
                alert.ValidDate       = BenQGuru.eMES.Web.Helper.FormatHelper.TODateInt(this.dateValidDate.Text);
                alert.MaintainDate    = BenQGuru.eMES.Web.Helper.FormatHelper.TODateInt(DateTime.Now.ToShortDateString());
                alert.MaintainUser    = this.GetUserCode();
                alert.MaintainTime    = FormatHelper.TOTimeInt(DateTime.Now);
                _alertBillFacade.AddAlertResBill(alert);

                //增加email通知人
                //if(this.chbMailNotify.Checked)
                //{
                for (int i = 0; i < this.lstUser.Items.Count; i++)
                {
                    if (this.lstUser.Items[i].Value != string.Empty)
                    {
                        BenQGuru.eMES.Domain.Alert.AlertNotifier user = new BenQGuru.eMES.Domain.Alert.AlertNotifier();
                        user.AlertItem = alert.AlertItem;
                        user.AlertType = alert.AlertType;
                        user.ItemCode  = alert.ItemCode;
                        user.UserCode  = this.lstUser.Items[i].Value;
                        user.EMail     = GetEMail(this.lstUser.Items[i].Text);
                        user.BillId    = alert.BillId;
                        if (_alertBillFacade.GetAlertNotifier(user.UserCode, user.BillId) == null)
                        {
                            _alertBillFacade.AddAlertNotifier(user);
                        }
                    }
                }
                //}
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        private void SaveData()
        {
            try
            {
                DataProvider.BeginTransaction();

                BenQGuru.eMES.Domain.Alert.AlertBill tempAlert = null;
                if (isResourceNG)
                {
                    BenQGuru.eMES.Domain.Alert.AlertResBill alert = (BenQGuru.eMES.Domain.Alert.AlertResBill) this._alertBillFacade.GetAlertResBill(this._billId);

                    //alert.BillId = this._billId;
                    //alert.ItemCode = _itemcode;
                    //alert.ResourceCode = _rescode;
                    //alert.ErrorGroup2Code = _ecg2ec;
                    //alert.AlertItem = this._alertitem;
                    //alert.AlertType = this._alerttype;
                    alert.AlertMsg    = this.txtAlertMsg.Text;
                    alert.Description = this.txtDesc.Text;

                    alert.Operator     = this.drpOperator.SelectedValue;
                    alert.StartNum     = int.Parse(this.txtStartNum.Text == ""?"0":this.txtStartNum.Text);
                    alert.MailNotify   = this.chbMailNotify.Checked?"Y":"N";
                    alert.LowValue     = decimal.Parse(this.txtLow.Text);
                    alert.UpValue      = decimal.Parse(this.txtUp.Text == ""?"0":this.txtUp.Text);
                    alert.ValidDate    = BenQGuru.eMES.Web.Helper.FormatHelper.TODateInt(this.dateValidDate.Text);
                    alert.MaintainDate = BenQGuru.eMES.Web.Helper.FormatHelper.TODateInt(DateTime.Now.ToShortDateString());
                    alert.MaintainUser = this.GetUserCode();
                    alert.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                    tempAlert          = (BenQGuru.eMES.Domain.Alert.AlertBill)alert;
                    _alertBillFacade.UpdateAlertResBill(alert);
                }
                else
                {
                    BenQGuru.eMES.Domain.Alert.AlertBill alert = (BenQGuru.eMES.Domain.Alert.AlertBill) this._alertBillFacade.GetAlertBill(this._billId);

                    //alert.BillId = this._billId;
                    //alert.ItemCode = _itemcode;
                    //alert.AlertItem = this._alertitem;
                    //alert.AlertType = this._alerttype;
                    alert.AlertMsg    = this.txtAlertMsg.Text;
                    alert.Description = this.txtDesc.Text;

                    alert.Operator     = this.drpOperator.SelectedValue;
                    alert.StartNum     = int.Parse(this.txtStartNum.Text == ""?"0":this.txtStartNum.Text);
                    alert.MailNotify   = this.chbMailNotify.Checked?"Y":"N";
                    alert.LowValue     = decimal.Parse(this.txtLow.Text);
                    alert.UpValue      = decimal.Parse(this.txtUp.Text == ""?"0":this.txtUp.Text);
                    alert.ValidDate    = BenQGuru.eMES.Web.Helper.FormatHelper.TODateInt(this.dateValidDate.Text);
                    alert.MaintainDate = BenQGuru.eMES.Web.Helper.FormatHelper.TODateInt(DateTime.Now.ToShortDateString());
                    alert.MaintainUser = this.GetUserCode();
                    alert.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                    tempAlert          = alert;
                    _alertBillFacade.UpdateAlertBill(alert);
                }
                //增加接收人
                if (tempAlert != null)
                {
                    object[] objs = _alertBillFacade.QueryAlertNotifier(tempAlert.BillId);
                    if (objs != null)
                    {
                        foreach (object obj in objs)
                        {
                            BenQGuru.eMES.Domain.Alert.AlertNotifier an = obj as BenQGuru.eMES.Domain.Alert.AlertNotifier;
                            if (an != null)
                            {
                                _alertBillFacade.DeleteAlertNotifier(an);
                            }
                        }
                    }
                }

                //if(this.chbMailNotify.Checked)
                //{
                for (int i = 0; i < this.lstUser.Items.Count; i++)
                {
                    if (this.lstUser.Items[i].Value != string.Empty)
                    {
                        BenQGuru.eMES.Domain.Alert.AlertNotifier user = new BenQGuru.eMES.Domain.Alert.AlertNotifier();
                        user.AlertItem = tempAlert.AlertItem;
                        user.AlertType = tempAlert.AlertType;
                        user.ItemCode  = tempAlert.ItemCode;
                        user.UserCode  = this.lstUser.Items[i].Value;
                        user.EMail     = GetEMail(this.lstUser.Items[i].Text);
                        user.BillId    = tempAlert.BillId;
                        if (_alertBillFacade.GetAlertNotifier(user.UserCode, user.BillId) == null)
                        {
                            _alertBillFacade.AddAlertNotifier(user);
                        }
                    }
                }
                //}

                DataProvider.CommitTransaction();
            }
            catch (System.Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                throw ex;
            }
        }
Example #3
0
        private void LoadResData()
        {
            this.ExecuteClientFunction("setResDisplay", "");
            BenQGuru.eMES.Domain.Alert.AlertResBill alert = (BenQGuru.eMES.Domain.Alert.AlertResBill) this._alertBillFacade.GetAlertResBill(this._billId);
            if (alert != null)
            {
                this.ViewState["_itemcode"] = alert.ItemCode;
                _alerttype = alert.AlertType;
                this.ViewState["_alertitem"] = alert.AlertItem;
                this.ViewState["_rescode"]   = alert.ResourceCode;
                this.ViewState["._ecg2ec"]   = alert.ErrorGroup2Code;

                this.txtResource.Text  = this.ViewState["_rescode"].ToString();
                this.txtEcg2Ec.Text    = this.ViewState["._ecg2ec"].ToString();
                this.txtItemCode.Text  = alert.ItemCode;
                this.txtAlertItem.Text = AlertMsg.GetAlertName(alert.AlertItem, this.languageComponent1);
                this.txtAlertType.Text = AlertMsg.GetAlertName(alert.AlertType, this.languageComponent1);

                //不良资源只有大于等于才有效
                if (this._alerttype == AlertType_Old.ResourceNG)
                {
                    this.txtStartNum.Text = string.Empty;
                    this.drpOperator.Items.RemoveAt(0);
                    this.drpOperator.Items.RemoveAt(0);
                }
                else
                {
                    this.txtStartNum.Text = NumberHelper.TrimZero(alert.StartNum);
                }

                this.drpOperator.SelectedValue = alert.Operator;
                if (this.drpOperator.SelectedValue != Operator_Old.BW)
                {
                    this.lblAnd.Visible = false;
                    this.txtUp.Visible  = false;
                }
                this.txtLow.Text           = NumberHelper.TrimZero(alert.LowValue);
                this.txtUp.Text            = NumberHelper.TrimZero(alert.UpValue);
                this.dateValidDate.Text    = FormatHelper.ToDateString(alert.ValidDate);
                this.txtAlertMsg.Text      = alert.AlertMsg;
                this.txtDesc.Text          = alert.Description;
                this.chbMailNotify.Checked = (alert.MailNotify == "Y");
                //load 用户
                //if(this.chbMailNotify.Checked)
                //{
                object[] objs = _alertBillFacade.QueryAlertNotifier(_billId);
                if (objs != null)
                {
                    foreach (object obj in objs)
                    {
                        BenQGuru.eMES.Domain.Alert.AlertNotifier notifier = obj as BenQGuru.eMES.Domain.Alert.AlertNotifier;
                        if (notifier == null)
                        {
                            continue;
                        }

                        BenQGuru.eMES.Domain.BaseSetting.User user = _userfacade.GetUser(notifier.UserCode) as BenQGuru.eMES.Domain.BaseSetting.User;
                        if (user != null && user.UserEmail != null)
                        {
                            this.lstUser.Items.Add(new ListItem(user.UserCode + "(" + user.UserEmail + ")", user.UserCode));
                        }
                        else                         //没找到则是手动加入的用户
                        {
                            this.lstUser.Items.Add(new ListItem(notifier.UserCode + "(" + notifier.EMail + ")", notifier.UserCode));
                        }
                    }
                }
                //}
            }
        }