Beispiel #1
0
        private void transformeListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TransformerListfrm transListForm = new TransformerListfrm();

            transListForm.UserID = UserID;
            transListForm.Show();
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (checkValidation())
            {
                if (isEdit)
                {
                    int TransformerName = 0;
                    TransformerName = (from tn in mbsEntities.Transformers where tn.TransformerName.Trim() == txtTransformerName.Text.Trim() && tn.TransformerID != TransformerID && tn.Active == true select tn).ToList().Count;
                    if (TransformerName == 0)
                    {
                        string      oldTransformerName;
                        Transformer updateTransformer = (from tf in mbsEntities.Transformers where tf.TransformerID == TransformerID select tf).FirstOrDefault();
                        oldTransformerName = updateTransformer.TransformerName;

                        updateTransformer.TransformerName   = txtTransformerName.Text;
                        updateTransformer.Model             = txtTransformerModel.Text;
                        updateTransformer.CountryOfOrgin    = txtCountryOrgin.Text;
                        updateTransformer.FullLoadLoss      = Convert.ToInt32(txtFullLoadLoss.Text);
                        updateTransformer.ImpendanceVoltage = Convert.ToInt32(txtImpedanceVoltage.Text);
                        updateTransformer.EfficiencyLoad    = Convert.ToInt32(txtEfficiency.Text);
                        updateTransformer.TappingRange      = txtTappingRange.Text;
                        updateTransformer.TypeofCooling     = txtTypeOfCooling.Text;
                        updateTransformer.VectorGroup       = txtVectorGroup.Text;
                        updateTransformer.VoltageRatio      = Convert.ToInt32(txtVoltageRatio.Text);
                        updateTransformer.Standard          = txtStandard.Text;
                        updateTransformer.NoloadLoss        = Convert.ToInt32(txtNoLoadLoss.Text);
                        updateTransformer.RatedOutputPower  = Convert.ToInt32(txtRatedPower.Text);
                        updateTransformer.Maker             = txtmaker.Text;

                        if (rdoEnable.Checked == true)
                        {
                            updateTransformer.Status = "Enable";
                        }
                        else
                        {
                            updateTransformer.Status = "Disable";
                        }


                        updateTransformer.QuarterID     = cboQuarterName.SelectedValue.ToString();
                        updateTransformer.UpdatedUserID = UserID;
                        updateTransformer.UpdateDate    = DateTime.Now;
                        transformerController.UpdateTransformer(updateTransformer);
                        if (oldTransformerName != txtTransformerName.Text)
                        {
                            TransformerHistory transformerHistory = new TransformerHistory();
                            transformerHistory.TransformerID      = Guid.NewGuid().ToString();
                            transformerHistory.OldTransformerName = oldTransformerName;
                            transformerHistory.TransformerName    = updateTransformer.TransformerName;
                            transformerHistory.Model             = updateTransformer.Model;
                            transformerHistory.CountryOfOrgin    = updateTransformer.CountryOfOrgin;
                            transformerHistory.FullLoadLoss      = updateTransformer.FullLoadLoss;
                            transformerHistory.ImpendanceVoltage = updateTransformer.ImpendanceVoltage;
                            transformerHistory.EfficiencyLoad    = updateTransformer.EfficiencyLoad;
                            transformerHistory.TappingRange      = updateTransformer.TappingRange;
                            transformerHistory.TypeofCooling     = updateTransformer.TypeofCooling;
                            transformerHistory.VectorGroup       = updateTransformer.VectorGroup;
                            transformerHistory.VoltageRatio      = updateTransformer.VoltageRatio;
                            transformerHistory.Standard          = updateTransformer.Standard;
                            transformerHistory.NoloadLoss        = updateTransformer.NoloadLoss;
                            transformerHistory.RatedOutputPower  = updateTransformer.RatedOutputPower;
                            transformerHistory.Maker             = updateTransformer.Maker;
                            transformerHistory.GPSX          = 0;
                            transformerHistory.GPSY          = 0;
                            transformerHistory.Status        = "Disable";
                            transformerHistory.CreatedUserID = updateTransformer.UpdatedUserID;
                            transformerHistory.CreatedDate   = DateTime.Now;
                            transformerHistory.QuarterID     = updateTransformer.QuarterID;
                            transformerHistory.Active        = true;
                            mbsEntities.TransformerHistories.Add(transformerHistory);
                            mbsEntities.SaveChanges();
                        }

                        MessageBox.Show("Successfully updated Transformer!", "Update");
                        Clear();
                        TransformerListfrm transformerListfrm = new TransformerListfrm();
                        transformerListfrm.Show();
                        this.Close();
                    }
                    else if (TransformerName > 0)
                    {
                        tooltip.SetToolTip(txtTransformerName, "Error");
                        tooltip.Show("This Transformer Name is already exist!", txtTransformerName);
                    }
                }
                else
                {
                    int TransformerName = 0;
                    TransformerName = (from tn in mbsEntities.Transformers where tn.TransformerName.Trim() == txtTransformerName.Text.Trim() && tn.Active == true select tn).ToList().Count;
                    if (TransformerName == 0)
                    {
                        Transformer transformer = new Transformer();
                        transformer.TransformerID     = Guid.NewGuid().ToString();
                        transformer.TransformerName   = txtTransformerName.Text;
                        transformer.Model             = txtTransformerModel.Text;
                        transformer.CountryOfOrgin    = txtCountryOrgin.Text;
                        transformer.FullLoadLoss      = Convert.ToInt32(txtFullLoadLoss.Text == ""?"0":txtFullLoadLoss.Text);
                        transformer.ImpendanceVoltage = Convert.ToInt32(txtImpedanceVoltage.Text == ""?"0":txtImpedanceVoltage.Text);
                        transformer.EfficiencyLoad    = Convert.ToInt32(txtEfficiency.Text == "" ?"0":txtEfficiency.Text);
                        transformer.TappingRange      = txtTappingRange.Text == ""?"0":txtTappingRange.Text;
                        transformer.TypeofCooling     = txtTypeOfCooling.Text == ""?"0":txtTypeOfCooling.Text;
                        transformer.VectorGroup       = txtVectorGroup.Text;
                        transformer.VoltageRatio      = Convert.ToInt32(txtVoltageRatio.Text == "" ?"0":txtVoltageRatio.Text);
                        transformer.Standard          = txtStandard.Text == "" ?"0":txtStandard.Text;
                        transformer.NoloadLoss        = Convert.ToInt32(txtNoLoadLoss.Text == "" ?"0":txtNoLoadLoss.Text);
                        transformer.RatedOutputPower  = Convert.ToInt32(txtRatedPower.Text == ""?"0":txtRatedPower.Text);
                        transformer.Maker             = txtmaker.Text;
                        if (rdoEnable.Checked == true)
                        {
                            transformer.Status = "Enable";
                        }
                        else
                        {
                            transformer.Status = "Disable";
                        }
                        transformer.QuarterID     = cboQuarterName.SelectedValue.ToString();
                        transformer.Active        = true;
                        transformer.CreatedUserID = UserID;
                        transformer.CreatedDate   = DateTime.Now;
                        transformerController.Save(transformer);
                        MessageBox.Show("Successfully registered Trasformer! Please check it in 'Transformer List'.", "Save Success");
                        Clear();
                    }
                    else if (TransformerName > 0)
                    {
                        tooltip.SetToolTip(txtTransformerName, "Error");
                        tooltip.Show("This Transformer Name is already exist!", txtTransformerName);
                    }
                }
            }
        }