Example #1
0
        private void initPage(long rackID)
        {
            RackInfo rackByID = RackInfo.getRackByID(rackID);

            if (rackByID == null)
            {
                return;
            }
            int num  = rackByID.StartPoint_X + 1;
            int num2 = rackByID.StartPoint_Y + 1;
            int num3 = rackByID.EndPoint_X + 1;
            int num4 = 0;

            if (num != num3)
            {
                num4 = 1;
            }
            this.tbRackNm.Text  = rackByID.OriginalName;
            this.tbRackFNm.Text = rackByID.RackFullName;
            this.tbRow.Text     = num.ToString();
            this.tbColumn.Text  = num2.ToString();
            if (num4 == 0)
            {
                this.rbH.Checked = true;
                return;
            }
            this.rbV.Checked = true;
        }
Example #2
0
 /// <summary>
 /// On doubleclicking on the grid, It displays the details to edit or delete a rack
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvRack_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             if (dgvRack.Rows[e.RowIndex].Cells["dgvtxtRackName"].Value.ToString() != "NA")
             {
                 RackSP   spRack   = new RackSP();
                 RackInfo infoRack = new RackInfo();
                 decRackId               = Convert.ToDecimal(dgvRack.Rows[e.RowIndex].Cells["dgvtxtRackId"].Value.ToString());
                 infoRack                = spRack.RackView(decRackId);
                 txtRackName.Text        = infoRack.RackName;
                 cmbGodown.SelectedValue = infoRack.GodownId.ToString();
                 txtNarration.Text       = infoRack.Narration;
                 btnSave.Text            = "Update";
                 btnDelete.Enabled       = true;
                 strRackName             = infoRack.RackName;
                 txtRackName.Focus();
             }
             else
             {
                 Messages.InformationMessage("Default Rack cannot update or delete");
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("R19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #3
0
 /// <summary>
 /// Function to save new rack
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         RackSP   spRack   = new RackSP();
         RackInfo rackInfo = new RackInfo();
         rackInfo.RackName  = txtRackName.Text.Trim();
         rackInfo.GodownId  = Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
         rackInfo.Narration = txtNarration.Text.Trim();
         rackInfo.ExtraDate = DateTime.Now;
         rackInfo.Extra1    = string.Empty;
         rackInfo.Extra2    = string.Empty;
         decimal decGodounId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
         if (spRack.RackCheckExistence(txtRackName.Text.Trim(), 0, decGodounId) == false)
         {
             decIdForOtherForms = spRack.RackAdd(rackInfo);
             if (decIdForOtherForms > 0)
             {
                 Messages.SavedMessage();
                 Clear();
             }
         }
         else
         {
             Messages.InformationMessage(" Rack name already exist");
             txtRackName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("R7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #4
0
        private static void RackAddGroupLeft(ITray rack, RackInfo rackInfo)
        {
            ITubesGroup group = rack.AddTubesGroup();

            group.SetEllipsoidForm(14.3, 14.3);  // Each tube/position is represented by a circle

            //                                                        10 tubes on X (horizontal)
            //                                                                                   15 tubes on Y (vertical)
            //                                                                                                           x, y position of the 1st tube
            //                                                                                                                 x   , y distance between tubes in x- and y-direction
            IRectangularTubeCollection rectangle = group.AddRectangle(rackInfo.TubeColumnsCount, rackInfo.TubeRowsCount, 4, 6, 15.8, 15.9);

            // EnumerationScheme.SawH means the tubes are enumerated from left to right, top to bottom
            //                                                                             A          151 - 1st tube number   , 151 - the global numerical index starts from 151 (the 1st tube)
            rectangle.AddEnumeration(EnumerationScheme.SawH, rackInfo.TubePositionNamePrefix + "%p%", rackInfo.TubeFirstNumber, rackInfo.TubeFirstNumber);

            /*
             *  10 columns x 15 rows (defined in group.AddRectangle(10, 15)
             *
             *  151 152 153 154 155 156 157 158 159 160
             *  161 162 163 164 165 166 167 168 169 170
             *  . . .
             *  291 292 293 294 295 296 297 298 299 300
             *
             *  Also, see int Position setter
             */
        }
Example #5
0
 private void x_path_grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (true)
     {
         var p = e.GetPosition(x_path_grid);
         foreach (var itemm in x_path_grid.Children)
         {
             if (itemm is Path)
             {
                 Path pitem = itemm as Path;
                 if (pitem.Tag != null)
                 {
                     if (pitem.Data is RectangleGeometry)
                     {
                         RectangleGeometry rect = pitem.Data as RectangleGeometry;
                         if (rect.Bounds.Contains(p))
                         {
                             string rackcode = pitem.Tag.ToString();
                             selectRack = rackList.Where(a => a.Rackcode == rackcode).FirstOrDefault();
                             SetSelectLayer("1");
                             //RouteShowSelect rss = new RouteShowSelect()
                             //{
                             //    selectRack = selectRack,
                             //    pRouteShow = this
                             //};
                             //rss.ShowDialog();
                         }
                     }
                 }
             }
         }
     }
 }
Example #6
0
 /// <summary>
 /// 设置选中的仓位
 /// </summary>
 /// <param name="rackname"></param>
 /// <param name="rackcode"></param>
 /// <param name="layernum"></param>
 public void SetSelectRack(string rackname, string rackcode, string layernum)
 {
     if (btn_select_type == 0)
     {
         cb_pack_route.ItemsSource = rackList;
         for (int i = 0; i < rackList.Count; i++)
         {
             RackInfo ri = rackList[i];
             if (ri.Rackname == rackname)
             {
                 cb_pack_route.SelectedIndex = i;
                 break;
             }
         }
     }
     else
     {
         cb_downpack_route.ItemsSource = rackList;
         for (int i = 0; i < rackList.Count; i++)
         {
             RackInfo ri = rackList[i];
             if (ri.Rackname == rackname)
             {
                 cb_downpack_route.SelectedIndex = i;
                 break;
             }
         }
     }
 }
Example #7
0
 private void chk_all_Unchecked(object sender, RoutedEventArgs e)
 {
     foreach (var item in dataGrid1.Items)
     {
         RackInfo ri = item as RackInfo;
         ri.IsChecked = false;
     }
 }
Example #8
0
        private void butDel_Click(object sender, System.EventArgs e)
        {
            if (this.lbRack.SelectedItem == null)
            {
                return;
            }
            this.closetips();
            int          selectedIndex = this.lbRack.SelectedIndex;
            string       text          = this.lbRack.SelectedItem.ToString();
            DialogResult dialogResult  = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Rack_delCrm, new string[]
            {
                text
            }), MessageBoxButtons.OKCancel);

            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }
            this.lbRack.Items.RemoveAt(selectedIndex);
            RackInfo rackInfo = (RackInfo)this.m_AllRacks[selectedIndex];

            this.m_AllRacks.RemoveAt(selectedIndex);
            this.m_MapID2Rack.Remove(rackInfo.RackID);
            this.delRackUi(rackInfo.RackID);
            RackInfo.DeleteByID(rackInfo.RackID);
            string valuePair = ValuePairs.getValuePair("Username");

            if (!string.IsNullOrEmpty(valuePair))
            {
                LogAPI.writeEventLog("0430011", new string[]
                {
                    text,
                    valuePair
                });
            }
            else
            {
                LogAPI.writeEventLog("0430011", new string[]
                {
                    text
                });
            }
            EcoGlobalVar.setDashBoardFlg(780uL, "", 64);
            if (this.lbRack.Items.Count == 0)
            {
                this.butDel.Enabled    = false;
                this.butModify.Enabled = false;
                return;
            }
            if (selectedIndex < this.lbRack.Items.Count)
            {
                this.lbRack.SelectedIndex = selectedIndex;
                return;
            }
            this.lbRack.SelectedIndex = this.lbRack.Items.Count - 1;
        }
Example #9
0
        private static void RackAddGroupRight(ITray rack, RackInfo rackInfo)
        {
            ITubesGroup group = rack.AddTubesGroup();

            group.SetEllipsoidForm(16.2, 16.2);

            IRectangularTubeCollection rectangle = group.AddRectangle(rackInfo.TubeColumnsCount, rackInfo.TubeRowsCount, 177.1, 17, 18, 18);

            rectangle.AddEnumeration(EnumerationScheme.SawH, rackInfo.TubePositionNamePrefix + "%p%", rackInfo.TubeFirstNumber, rackInfo.TubeFirstNumber);
        }
Example #10
0
        public bool addRack(int column, int row, string direction, string rackNm, string rackFNm)
        {
            if (!this.checkMove(direction, row, column, -1L))
            {
                return(false);
            }
            int i_ex;
            int i_ey;

            if (direction.Equals("H"))
            {
                i_ex = row;
                i_ey = column + 1;
            }
            else
            {
                i_ex = row + 1;
                i_ey = column;
            }
            long   num       = RackInfo.CreateRackInfo(rackNm, "", row, column, i_ex, i_ey, rackFNm);
            string valuePair = ValuePairs.getValuePair("Username");

            if (!string.IsNullOrEmpty(valuePair))
            {
                LogAPI.writeEventLog("0430010", new string[]
                {
                    rackNm,
                    valuePair
                });
            }
            else
            {
                LogAPI.writeEventLog("0430010", new string[]
                {
                    rackNm
                });
            }
            this.initRackList();
            bool flag = commDev.updateZoneforRack(this.m_MapID2Rack[num]);

            this.addRackUI(column, row, direction, rackNm, "", num);
            RackInfo rackInfo = this.m_MapID2Rack[num];

            this.lbRack.SelectedItem = rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
            ulong num2      = 516uL;
            int   appAction = 0;

            if (flag)
            {
                num2 |= 264uL;
            }
            EcoGlobalVar.setDashBoardFlg(num2, "", appAction);
            return(true);
        }
Example #11
0
        public RackInfo RackView(decimal rackId)
        {
            RackInfo rackinfo = new RackInfo();

            try
            {
                rackinfo = SPRack.RackView(rackId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("RackBll 6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(rackinfo);
        }
Example #12
0
        public bool RackEdit(RackInfo rackinfo)
        {
            bool isEdit = false;

            try
            {
                isEdit = SPRack.RackEdit(rackinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("RackBll 4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(isEdit);
        }
Example #13
0
        public decimal RackAdd(RackInfo rackinfo)
        {
            decimal decEffectedRow = 0;

            try
            {
                decEffectedRow = SPRack.RackAdd(rackinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("RackBll 3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(decEffectedRow);
        }
Example #14
0
 /// <summary>
 /// Function to edit the existing rack
 /// </summary>
 public void EditFunction()
 {
     try
     {
         RackSP   spRack   = new RackSP();
         RackInfo rackInfo = new RackInfo();
         rackInfo.RackName  = txtRackName.Text.Trim();
         rackInfo.GodownId  = Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
         rackInfo.Narration = txtNarration.Text.Trim();
         rackInfo.ExtraDate = DateTime.Now;
         rackInfo.Extra1    = string.Empty;
         rackInfo.Extra2    = string.Empty;
         rackInfo.RackId    = decRackId;
         if (txtRackName.Text != strRackName)
         {
             if (CheckExistenceOfRackName() == false)
             {
                 if (spRack.RackEdit(rackInfo))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
             }
             else
             {
                 Messages.InformationMessage("Already exists");
                 txtRackName.Focus();
             }
         }
         else if (rackInfo.RackId == 1)
         {
             Messages.InformationMessage("Cannot update");
             Clear();
             txtRackName.Focus();
         }
         else
         {
             if (spRack.RackEdit(rackInfo))
             {
                 Messages.UpdatedMessage();
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("R8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #15
0
 private void dataGrid1_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
 {
     if (e.EditingElement is TextBox)
     {
         string newValue = (e.EditingElement as TextBox).Text;
         if (oldValue != newValue)
         {
             RackInfo ri = e.Row.Item as RackInfo;
             if (ri != null)
             {
                 x_rService.UpdateRow(e.Column.SortMemberPath, newValue, ri.Id);
             }
         }
     }
 }
Example #16
0
        private void butDevicesDel_Click(object sender, System.EventArgs e)
        {
            if (this.dgvAllDevices.SelectedRows.Count == 0)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_needselect, new string[0]));
                return;
            }
            DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_delCrm, new string[0]), MessageBoxButtons.OKCancel);

            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }
            System.Collections.ArrayList arrayList = new System.Collections.ArrayList();
            for (int i = 0; i < this.dgvAllDevices.SelectedRows.Count; i++)
            {
                DataGridViewCellCollection cells = this.dgvAllDevices.SelectedRows[i].Cells;
                string value = cells["dgvtbcdeviceId"].Value.ToString();
                arrayList.Insert(0, value);
            }
            System.Collections.ArrayList allRack_NoEmpty = RackInfo.GetAllRack_NoEmpty();
            Program.IdleTimer_Pause(1);
            progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_delDev, new string[0]), null, new progressPopup.ProcessInThread(this.delDevicePro), arrayList, 0);

            progressPopup.ShowDialog();
            object return_V = progressPopup.Return_V;

            Program.IdleTimer_Run(1);
            int?num = return_V as int?;

            if (!num.HasValue || num < 0)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0]));
            }
            System.Collections.ArrayList allRack_NoEmpty2 = RackInfo.GetAllRack_NoEmpty();
            EcoGlobalVar.gl_DevManPage.FlushFlg_RackBoard = 1;
            if (allRack_NoEmpty.Count == allRack_NoEmpty2.Count)
            {
                EcoGlobalVar.setDashBoardFlg(526uL, "", 66);
            }
            else
            {
                EcoGlobalVar.setDashBoardFlg(526uL, "", 65);
            }
            EcoGlobalVar.gl_DevManPage.FlushFlg_ZoneBoard = 1;
            this.changeTreeSelect("DevRoot");
        }
Example #17
0
        private void Rack_MouseDown(object sender, MouseEventArgs e)
        {
            if (this.toolTip1 != null)
            {
                this.rdl = null;
                this.toolTip1.Close();
            }
            DataGridView.HitTestInfo hitTestInfo = this.dgvSetDevice.HitTest(e.X, e.Y);
            this.rowIndexFromMouseDown = hitTestInfo.RowIndex;
            if (this.rowIndexFromMouseDown < 0)
            {
                return;
            }
            this.colIndexFromMouseDown = hitTestInfo.ColumnIndex;
            if (this.colIndexFromMouseDown < 0)
            {
                return;
            }
            DataGridViewSpanCell dataGridViewSpanCell = (DataGridViewSpanCell)this.dgvSetDevice.Rows[this.rowIndexFromMouseDown].Cells[this.colIndexFromMouseDown];

            if (dataGridViewSpanCell.GetColumnSpan() == 0 && dataGridViewSpanCell.GetRowSpan() == 0)
            {
                this.dragBoxFromMouseDown = Rectangle.Empty;
                return;
            }
            if (dataGridViewSpanCell.GetColumnSpan() < 0)
            {
                this.colIndexFromMouseDown--;
            }
            if (dataGridViewSpanCell.GetRowSpan() < 0)
            {
                this.rowIndexFromMouseDown--;
            }
            long     key      = (long)dataGridViewSpanCell.Tag;
            RackInfo rackInfo = this.m_MapID2Rack[key];

            this.lbRack.SelectedItem = rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
            if (this.dragBoxFromMouseDown != Rectangle.Empty && this.dragBoxFromMouseDown.Contains(e.X, e.Y))
            {
                return;
            }
            Size dragSize = SystemInformation.DragSize;

            this.dragBoxFromMouseDown = new Rectangle(new Point(e.X - dragSize.Width / 2, e.Y - dragSize.Height / 2), dragSize);
            this.dgvSetDevice.DoDragDrop(this.dgvSetDevice.Rows[this.rowIndexFromMouseDown].Cells[this.colIndexFromMouseDown], DragDropEffects.Move);
        }
Example #18
0
 private void initRackList()
 {
     this.m_AllRacks = RackInfo.getAllRack();
     this.m_MapID2Rack.Clear();
     this.lbRack.Items.Clear();
     for (int i = 0; i < this.m_AllRacks.Count; i++)
     {
         RackInfo rackInfo = (RackInfo)this.m_AllRacks[i];
         this.m_MapID2Rack.Add(rackInfo.RackID, rackInfo);
         string displayRackName = rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
         this.lbRack.Items.Add(displayRackName);
     }
     if (this.lbRack.Items.Count > 0)
     {
         this.lbRack.SelectedIndex = 0;
     }
 }
Example #19
0
 private void tvUserDeviceInit()
 {
     this.dgvAllDevices.Rows.Clear();
     string[] source = this.m_deviceIds.Split(new char[]
     {
         ','
     });
     System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
     for (int i = 0; i < allDevice.Count; i++)
     {
         DeviceInfo deviceInfo      = allDevice[i];
         string     deviceIP        = deviceInfo.DeviceIP;
         string     mac             = deviceInfo.Mac;
         string     deviceName      = deviceInfo.DeviceName;
         string     modelNm         = deviceInfo.ModelNm;
         RackInfo   rackByID        = RackInfo.getRackByID(deviceInfo.RackID);
         string     displayRackName = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
         string     text            = deviceInfo.DeviceID.ToString();
         if (source.Contains(text))
         {
             this.dgvAllDevices.Rows.Add(new object[]
             {
                 true,
                 deviceName,
                 mac,
                 deviceIP,
                 modelNm,
                 displayRackName,
                 text
             });
         }
         else
         {
             this.dgvAllDevices.Rows.Add(new object[]
             {
                 false,
                 deviceName,
                 mac,
                 deviceIP,
                 modelNm,
                 displayRackName,
                 text
             });
         }
     }
 }
Example #20
0
 /// <summary>
 /// Function to Update values in Rack Table
 /// </summary>
 /// <param name="rackinfo"></param>
 /// <returns></returns>
 public bool RackEdit(RackInfo rackinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RackEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal);
         sprmparam.Value = rackinfo.RackId;
         sprmparam       = sccmd.Parameters.Add("@rackName", SqlDbType.VarChar);
         sprmparam.Value = rackinfo.RackName;
         sprmparam       = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal);
         sprmparam.Value = rackinfo.GodownId;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = rackinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = rackinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = rackinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = rackinfo.Extra2;
         int inEffectedRow = sccmd.ExecuteNonQuery();
         if (inEffectedRow > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         return(false);
     }
     finally
     {
         sqlcon.Close();
     }
 }
Example #21
0
        private void butModify_Click(object sender, System.EventArgs e)
        {
            if (this.lbRack.SelectedItem == null)
            {
                return;
            }
            int      selectedIndex = this.lbRack.SelectedIndex;
            RackInfo rackInfo      = (RackInfo)this.m_AllRacks[selectedIndex];

            if (rackInfo == null)
            {
                return;
            }
            this.closetips();
            RackInfoDlg rackInfoDlg = new RackInfoDlg(this, rackInfo.RackID);

            rackInfoDlg.ShowDialog(this);
        }
Example #22
0
 private void treeMenuInit()
 {
     this.tvZone.Nodes.Clear();
     System.Collections.ArrayList allZone         = ZoneInfo.getAllZone();
     System.Collections.ArrayList allRack_NoEmpty = RackInfo.GetAllRack_NoEmpty();
     for (int i = 0; i < allZone.Count; i++)
     {
         ZoneInfo zoneInfo  = (ZoneInfo)allZone[i];
         string   zoneName  = zoneInfo.ZoneName;
         string   rackInfo  = zoneInfo.RackInfo;
         string   text      = zoneInfo.StartPointX.ToString() + "," + zoneInfo.StartPointY.ToString();
         string   text2     = zoneInfo.EndPointX.ToString() + "," + zoneInfo.EndPointY.ToString();
         string   zoneColor = zoneInfo.ZoneColor;
         TreeNode treeNode  = new TreeNode();
         treeNode.Text = zoneName;
         treeNode.Name = rackInfo;
         treeNode.Tag  = string.Concat(new string[]
         {
             text,
             "|",
             text2,
             "|",
             zoneColor,
             "|",
             zoneInfo.ZoneID.ToString()
         });
         string[] source = rackInfo.Split(new char[]
         {
             ','
         });
         foreach (RackInfo rackInfo2 in allRack_NoEmpty)
         {
             if (source.Contains(rackInfo2.RackID.ToString()) && rackInfo2 != null && !rackInfo2.DeviceInfo.Equals(string.Empty))
             {
                 string   displayRackName = rackInfo2.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
                 TreeNode treeNode2       = new TreeNode();
                 treeNode2.Text = displayRackName;
                 treeNode2.Name = "rack";
                 treeNode.Nodes.Add(treeNode2);
             }
         }
         this.tvZone.Nodes.Add(treeNode);
     }
 }
Example #23
0
 /// <summary>
 /// Function to Save Rack
 /// </summary>
 public void RackAddCurrespondingtoGodown()
 {
     try
     {
         RackSP   spRack   = new RackSP();
         RackInfo infoRack = new RackInfo();
         infoRack.RackName  = "NA";
         infoRack.GodownId  = decIdForOtherForms;
         infoRack.Narration = string.Empty;
         infoRack.Extra1    = string.Empty;
         infoRack.Extra2    = string.Empty;
         infoRack.ExtraDate = DateTime.Now;
         spRack.RackAdd(infoRack);
     }
     catch (Exception ex)
     {
         MessageBox.Show("G3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #24
0
 public decimal RackAdd(RackInfo rackinfo)
 {
     try
     {
         if (base.sqlcon.State == ConnectionState.Closed)
         {
             base.sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RackAdd", base.sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam7 = new SqlParameter();
         sprmparam7       = sccmd.Parameters.Add("@rackName", SqlDbType.VarChar);
         sprmparam7.Value = rackinfo.RackName;
         sprmparam7       = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal);
         sprmparam7.Value = rackinfo.GodownId;
         sprmparam7       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam7.Value = rackinfo.Narration;
         sprmparam7       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam7.Value = rackinfo.ExtraDate;
         sprmparam7       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam7.Value = rackinfo.Extra1;
         sprmparam7       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam7.Value = rackinfo.Extra2;
         decimal decEffectedRow = Convert.ToDecimal(sccmd.ExecuteScalar());
         if (decEffectedRow > 0m)
         {
             return(decEffectedRow);
         }
         return(0m);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         return(0m);
     }
     finally
     {
         base.sqlcon.Close();
     }
 }
Example #25
0
        /// <summary>
        /// Function to get particular values from Rack Table based on the parameter
        /// </summary>
        /// <param name="rackId"></param>
        /// <returns></returns>
        public RackInfo RackView(decimal rackId)
        {
            RackInfo      rackinfo  = new RackInfo();
            SqlDataReader sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("RackView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal);
                sprmparam.Value = rackId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    rackinfo.RackId    = decimal.Parse(sdrreader[0].ToString());
                    rackinfo.RackName  = sdrreader[1].ToString();
                    rackinfo.GodownId  = decimal.Parse(sdrreader[2].ToString());
                    rackinfo.Narration = sdrreader[3].ToString();
                    rackinfo.Extra1    = sdrreader[4].ToString();
                    rackinfo.Extra2    = sdrreader[5].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(rackinfo);
        }
Example #26
0
        private void btn_save_Click(object sender, RoutedEventArgs e)
        {
            string trcode  = tb_code.Text;
            string trname  = tb_name.Text;
            string trcount = cb_layercount.Text;
            string trroute = cb_routelist.Text;

            if (rackId == 0)
            {
                RackInfo trInfo = new RackInfo()
                {
                    Createtime = DateTime.Now,
                    Isvalid    = 1,
                    Updatetime = DateTime.Now
                };
                trInfo.Rackcode       = trcode;
                trInfo.Rackname       = trname;
                trInfo.RacklayerCount = Convert.ToInt32(trcount);
                trInfo.RouteCode      = trroute;
                trInfo.HouseId        = MainWindow.HouseId;
                x_rkService.Insert(trInfo);
            }
            else
            {
                x_rkService.Update(() => new RackInfo()
                {
                    Rackcode = trcode, Rackname = trname, RacklayerCount = Convert.ToInt32(trcount), RouteCode = trroute
                }, a => a.Id == rackId);
            }
            tb_code.Text = "";
            tb_name.Text = "";
            MsgBox.Show("保存成功");
            if (win_rkIndex != null && win_rkIndex.IsVisible)
            {
                win_rkIndex.InitData();
            }
        }
Example #27
0
        private void OneTableUpdate(object obj)
        {
            StorageContext storageContext = (StorageContext)obj;
            TickTimer      tickTimer      = new TickTimer();

            tickTimer.Start();
            DataWareHouse.WriteLog(string.Format("EEEEEEEEEEEEEEEEE [{0}] Table: {1}", Thread.CurrentThread.Name, storageContext._tablePrefix + storageContext._tableSuffix), new string[0]);
            DbConnection dbConnection = null;
            DbCommand    dbCommand    = null;

            try
            {
                if (storageContext._deviceVoltageList != null)
                {
                    DeviceOperation.UpdateDeviceVoltage(storageContext._deviceVoltageList);
                }
                else
                {
                    if (storageContext._lastSensorMaxValue != null)
                    {
                        RackInfo.GenerateAllRackThermal(storageContext._lastSensorMaxValue, storageContext._tDataTime);
                    }
                    else
                    {
                        if (storageContext._AllData4Access != null)
                        {
                            DataWareHouse.AccessMinuteData(storageContext._AllData4Access, 1, storageContext._tDataTime);
                        }
                        else
                        {
                            try
                            {
                                string arg;
                                if (storageContext._tablePrefix.StartsWith("dev_min_"))
                                {
                                    arg = "device_id";
                                }
                                else
                                {
                                    if (!storageContext._tablePrefix.StartsWith("port_min_"))
                                    {
                                        return;
                                    }
                                    arg = "port_id";
                                }
                                dbConnection = new MySqlConnection(string.Concat(new object[]
                                {
                                    "Database=",
                                    DBUrl.DB_CURRENT_NAME,
                                    ";Data Source=",
                                    DBUrl.CURRENT_HOST_PATH,
                                    ";Port=",
                                    DBUrl.CURRENT_PORT,
                                    ";User Id=",
                                    DBUrl.CURRENT_USER_NAME,
                                    ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=150;Default Command Timeout=0;charset=utf8;"
                                }));
                                dbConnection.Open();
                                dbCommand = dbConnection.CreateCommand();
                                try
                                {
                                    string text   = string.Format("insert into {0}{1} ({2},power_consumption,power,insert_time) values ", storageContext._tablePrefix, storageContext._tableSuffix, arg);
                                    int    num    = storageContext._tDataTime.Hour * 60 + storageContext._tDataTime.Minute;
                                    string format = string.Format("({{{0}}},{{{1}}},{{{2}}},{3})", new object[]
                                    {
                                        "0",
                                        "1",
                                        "2",
                                        num
                                    });
                                    string        text2         = "";
                                    StringBuilder stringBuilder = new StringBuilder();
                                    int           count         = storageContext._htData.Count;
                                    int           num2          = 0;
                                    stringBuilder.Append(text);
                                    foreach (DictionaryEntry dictionaryEntry in storageContext._htData)
                                    {
                                        num2++;
                                        try
                                        {
                                            double value = storageContext._dataRatio * Convert.ToDouble(dictionaryEntry.Value);
                                            string arg2  = string.Format("{0}", Convert.ToInt64(value));
                                            text2 = "";
                                            string text3 = string.Format(format, dictionaryEntry.Key, "null", arg2);
                                            if (stringBuilder.Length > text.Length)
                                            {
                                                stringBuilder.Append(",");
                                            }
                                            stringBuilder.Append(text3);
                                            if ((num2 >= count || (long)(stringBuilder.Length + text3.Length) > this._maxPacketLength / 2L) && stringBuilder.Length > 0)
                                            {
                                                dbCommand.CommandText = stringBuilder.ToString();
                                                text2 = dbCommand.CommandText;
                                                dbCommand.ExecuteNonQuery();
                                                stringBuilder.Clear();
                                                stringBuilder.Append(text);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            if (ex.GetType().FullName.Equals("MySql.Data.MySqlClient.MySqlException"))
                                            {
                                                try
                                                {
                                                    if (!string.IsNullOrEmpty(text2))
                                                    {
                                                        dbCommand.CommandText = text2;
                                                        dbCommand.ExecuteNonQuery();
                                                    }
                                                }
                                                catch (Exception ex2)
                                                {
                                                    DataWareHouse.WriteLog("Insert data: {0}{1}, Error:{2}", new string[]
                                                    {
                                                        storageContext._tablePrefix,
                                                        storageContext._tableSuffix,
                                                        ex.Message
                                                    });
                                                    if (!string.IsNullOrEmpty(text2) && ex2.GetType().FullName.Equals("MySql.Data.MySqlClient.MySqlException"))
                                                    {
                                                        string tableName = DBUtil.GetTableName(text2);
                                                        if (tableName != null && tableName.Length > 0)
                                                        {
                                                            DBUtil.SetMySQLInfo(tableName);
                                                        }
                                                        DataWareHouse.WriteLog("        MySQL database may be crashed, EcoSensor Monitor Service will shutdown ", new string[0]);
                                                        DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex2.Message + "\n" + ex2.StackTrace);
                                                        DBTools.Write_DBERROR_Log();
                                                        DBUtil.StopService();
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }
                            catch (Exception ex3)
                            {
                                if (ex3.GetType().FullName.Equals("MySql.Data.MySqlClient.MySqlException"))
                                {
                                    DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex3.Message + "\n" + ex3.StackTrace);
                                    DBTools.Write_DBERROR_Log();
                                    DBUtil.StopService();
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                try
                {
                    if (dbCommand != null)
                    {
                        dbCommand.Dispose();
                    }
                    if (dbConnection != null)
                    {
                        dbConnection.Close();
                        dbConnection.Dispose();
                    }
                }
                catch
                {
                }
                if (storageContext._htData != null)
                {
                    DataWareHouse.WriteLog(string.Format("----------------- [{0}] finished, count={1}, elapsed={2}", Thread.CurrentThread.Name + " " + storageContext._tablePrefix + storageContext._tableSuffix, storageContext._htData.Count, tickTimer.getElapsed().ToString()), new string[0]);
                }
                else
                {
                    DataWareHouse.WriteLog(string.Format("----------------- [{0}] finished, elapsed={1}", Thread.CurrentThread.Name + " " + storageContext._tablePrefix + storageContext._tableSuffix, tickTimer.getElapsed().ToString()), new string[0]);
                }
                if (storageContext._finishSignal != null)
                {
                    storageContext._finishSignal.Release();
                }
                if (storageContext._finishCounter != null)
                {
                    storageContext._finishCounter.Release();
                }
            }
        }
Example #28
0
        public static bool updateZoneforRack(RackInfo pRack)
        {
            if (pRack == null)
            {
                return(false);
            }
            System.Collections.ArrayList allZone = ZoneInfo.getAllZone();
            bool   result       = false;
            string text         = pRack.RackID.ToString();
            int    startPoint_X = pRack.StartPoint_X;
            int    startPoint_Y = pRack.StartPoint_Y;
            int    endPoint_X   = pRack.EndPoint_X;
            int    arg_3A_0     = pRack.EndPoint_Y;
            int    num;

            if (startPoint_X == endPoint_X)
            {
                num = 0;
            }
            else
            {
                num = 1;
            }
            foreach (ZoneInfo zoneInfo in allZone)
            {
                string   rackInfo = zoneInfo.RackInfo;
                string[] array    = rackInfo.Split(new char[]
                {
                    ','
                });
                int    startPointX = zoneInfo.StartPointX;
                int    startPointY = zoneInfo.StartPointY;
                int    endPointX   = zoneInfo.EndPointX;
                int    endPointY   = zoneInfo.EndPointY;
                bool   flag        = false;
                string text2       = "";
                bool   flag2       = false;
                if (((startPoint_X <= startPointX && startPoint_X >= endPointX) || (startPoint_X >= startPointX && startPoint_X <= endPointX)) && ((startPoint_Y <= startPointY && startPoint_Y >= endPointY) || (startPoint_Y >= startPointY && startPoint_Y <= endPointY)))
                {
                    flag2 = true;
                }
                else
                {
                    if (num == 0)
                    {
                        if (((startPoint_X <= startPointX && startPoint_X >= endPointX) || (startPoint_X >= startPointX && startPoint_X <= endPointX)) && ((startPoint_Y + 1 <= startPointY && startPoint_Y + 1 >= endPointY) || (startPoint_Y + 1 >= startPointY && startPoint_Y + 1 <= endPointY)))
                        {
                            flag2 = true;
                        }
                    }
                    else
                    {
                        if (num == 1 && ((startPoint_X + 1 <= startPointX && startPoint_X + 1 >= endPointX) || (startPoint_X + 1 >= startPointX && startPoint_X + 1 <= endPointX)) && ((startPoint_Y <= startPointY && startPoint_Y >= endPointY) || (startPoint_Y >= startPointY && startPoint_Y <= endPointY)))
                        {
                            flag2 = true;
                        }
                    }
                }
                if (flag2)
                {
                    if (array.Contains(text))
                    {
                        continue;
                    }
                    if (array.Length == 1 && array[0].Equals(string.Empty))
                    {
                        text2 = text;
                    }
                    else
                    {
                        string[] array2 = array;
                        for (int i = 0; i < array2.Length; i++)
                        {
                            string text3 = array2[i];
                            if (text2.Equals(string.Empty))
                            {
                                text2 = text3;
                            }
                            else
                            {
                                text2 = text2 + "," + text3;
                            }
                        }
                        if (text2.Equals(string.Empty))
                        {
                            text2 = text;
                        }
                        else
                        {
                            text2 = text2 + "," + text;
                        }
                    }
                    flag = true;
                }
                else
                {
                    if (array.Contains(text))
                    {
                        string[] array3 = array;
                        for (int j = 0; j < array3.Length; j++)
                        {
                            string text4 = array3[j];
                            if (!text4.Equals(text))
                            {
                                if (text2.Equals(string.Empty))
                                {
                                    text2 = text4;
                                }
                                else
                                {
                                    text2 = text2 + "," + text4;
                                }
                            }
                        }
                        flag = true;
                    }
                }
                if (flag)
                {
                    result            = true;
                    zoneInfo.RackInfo = text2;
                    zoneInfo.UpdateZone();
                }
            }
            return(result);
        }
 /// <summary>
 /// On doubleclicking on the grid, It displays the details to edit or delete a rack 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvRack_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             if (dgvRack.Rows[e.RowIndex].Cells["dgvtxtRackName"].Value.ToString() != "NA")
             {
                 RackBll BllRack = new RackBll();
                 RackInfo infoRack = new RackInfo();
                 decRackId = Convert.ToDecimal(dgvRack.Rows[e.RowIndex].Cells["dgvtxtRackId"].Value.ToString());
                 infoRack = BllRack.RackView(decRackId);
                 txtRackName.Text = infoRack.RackName;
                 cmbGodown.SelectedValue = infoRack.GodownId.ToString();
                 txtNarration.Text = infoRack.Narration;
                 btnSave.Text = "Update";
                 btnDelete.Enabled = true;
                 strRackName = infoRack.RackName;
                 txtRackName.Focus();
             }
             else
             {
                 Messages.InformationMessage("Default Rack cannot update or delete");
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("R19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to save new rack
 /// </summary>
 public void SaveFunction()
 {
     try
     {
             RackBll BllRack = new RackBll();
             RackInfo InfoRack = new RackInfo();
             InfoRack.RackName = txtRackName.Text.Trim();
             InfoRack.GodownId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
             InfoRack.Narration = txtNarration.Text.Trim();
             InfoRack.ExtraDate = DateTime.Now;
             InfoRack.Extra1 = string.Empty;
             InfoRack.Extra2 = string.Empty;
             decimal decGodounId=Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
             if (BllRack.RackCheckExistence(txtRackName.Text.Trim(), 0, decGodounId) == false)
             {
                 decIdForOtherForms = BllRack.RackAdd(InfoRack);
                 if (decIdForOtherForms > 0)
                 {
                     Messages.SavedMessage();
                     Clear();
                 }
             }
             else
             {
                 Messages.InformationMessage(" Rack name already exist");
                 txtRackName.Focus();
             }
     }
     catch (Exception ex)
     {
         MessageBox.Show("R7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #31
0
 /// <summary>
 /// Function to add the products to grid
 /// </summary>
 public void AddToGrid()
 {
     BatchBll BllBatch = new BatchBll();
     GodownBll BllGodown = new GodownBll();
     try
     {
         SettingsBll BllSettings = new SettingsBll();
         if (txtProductCode.Text.Trim() == null && txtProductCode.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter product code");
             txtProductCode.Focus();
         }
         else if (cmbItem.SelectedIndex == -1 && cmbItem.SelectedValue == null)
         {
             Messages.InformationMessage("Select a product");
             cmbItem.Focus();
         }
         else if (Convert.ToDecimal(txtQuantity.Text.Trim()) <= 0 || txtQuantity.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter quantity");
             txtQuantity.Focus();
         }
         else if (cmbUnit.SelectedValue == null)
         {
             Messages.InformationMessage("Select a unit");
             cmbUnit.Focus();
         }
         else if (BllSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && decimal.Parse(txtRate.Text.Trim()) <= 0 || txtRate.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter rate");
             txtRate.Focus();
         }
         else
         {
             int inCurrentRowIndex = new int();
             bool isExecutef = false;
             if (rowIdToEdit == 0)
             {
                 dgvPointOfSales.Rows.Add();
                 inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1;
                 isExecutef = true;
             }
             else
             {
                 for (int i = 0; i < dgvPointOfSales.Rows.Count; ++i)
                 {
                     if (dgvPointOfSales.Rows[i].Cells["rowId"].Value.ToString() == rowIdToEdit.ToString())
                     {
                         isExecutef = true;
                         inCurrentRowIndex = i;
                         break;
                     }
                 }
             }
             if (!isExecutef)
             {
                 dgvPointOfSales.Rows.Add();
                 inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1;
             }
             ProductInfo infoProduct = new ProductInfo();
             BatchInfo infoBatch = new BatchInfo();
             RackInfo infoRack = new RackInfo();
             ProductCreationBll BllProductCreation = new ProductCreationBll();
             UnitConvertionInfo InfoUnitConvertion = new UnitConvertionInfo();
             infoProduct = BllProductCreation.ProductView(decProductId);
             decimal dcProductBatch = BllBatch.BatchIdViewByProductId(decProductId);
             InfoUnitConvertion = new UnitConvertionBll().UnitViewAllByProductId(decProductId);
             infoBatch = BllBatch.BatchView(dcProductBatch);
             decimal dcGodownId = infoProduct.GodownId;
             GodownInfo infoGodown = new GodownInfo();
             infoGodown = BllGodown.GodownView(dcGodownId);
             decimal dcRackId = infoProduct.RackId;
             infoRack = new RackBll().RackView(dcRackId);
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductCode"].Value = txtProductCode.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductName"].Value = cmbItem.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtQuantity"].Value = txtQuantity.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnit"].Value = cmbUnit.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = txtRate.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGrossValue"].Value = txtGrossValue.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxPercentage"].Value = cmbTax.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxAmount"].Value = txtTaxAmount.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtNetAmount"].Value = txtNetAmount.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtDiscount"].Value = txtDiscountAmount.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTotalAmount"].Value = txtAmount.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxttaxid"].Value = Convert.ToDecimal(cmbTax.SelectedValue);
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductId"].Value = infoProduct.ProductId;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchId"].Value = dcProductBatch;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackId"].Value = infoProduct.RackId;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownId"].Value = infoProduct.GodownId;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnitId"].Value = Convert.ToDecimal(cmbUnit.SelectedValue);
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtunitconversionId"].Value = InfoUnitConvertion.UnitconvertionId;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = txtBarcode.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchno"].Value = infoBatch.BatchNo;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownName"].Value = infoGodown.GodownName;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackName"].Value = infoRack.RackName;
             TotalAmountCalculation();
             ClearGroupbox();
             dgvPointOfSales.CurrentCell = dgvPointOfSales[0, dgvPointOfSales.Rows.Count - 1];
             txtBarcode.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("POS:34" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Work on dgvProductCreation CellEndEdit event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvProductCreation_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvtxtbatch")
         {
             string strBatch = dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null ? "" : dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
             if (strBatch != "")
             {
                 BatchBll BllBatch = new BatchBll();
                 List<DataTable> listBatch = new List<DataTable>();
                 listBatch = BllBatch.BatchViewByName(strBatch, decId);
                 if (listBatch[0].Rows.Count != 0)
                 {
                     dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = listBatch[0].Rows[0]["expiryDate"];
                     dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = listBatch[0].Rows[0]["manufacturingDate"];
                 }
             }
             else
             {
                 dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = string.Empty;
                 dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = string.Empty;
             }
         }
         if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvcmbtgodown")
         {
             RackBll BllRack = new RackBll();
             RackInfo infoRack = new RackInfo();
             List<DataTable> listObjRack = new List<DataTable>();
             decimal decGodownId = Convert.ToDecimal(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbtgodown"].Value);
             listObjRack = BllRack.RackNamesCorrespondingToGodownId(decGodownId);
             DataRow drow = listObjRack[0].NewRow();
             drow["rackName"] = string.Empty;
             drow["rackId"] = 0;
             listObjRack[0].Rows.InsertAt(drow, 0);
             DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbrack"]);
             cell.DataSource = listObjRack[0];
             cell.ValueMember = "rackId";
             cell.DisplayMember = "rackName";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to Save Rack 
 /// </summary>
 public void RackAddCurrespondingtoGodown()
 {
     try
     {
         RackBll BllRack = new RackBll();
         RackInfo infoRack = new RackInfo();
         infoRack.RackName = "NA";
         infoRack.GodownId = decIdForOtherForms;
         infoRack.Narration = string.Empty;
         infoRack.Extra1 = string.Empty;
         infoRack.Extra2 = string.Empty;
         infoRack.ExtraDate = DateTime.Now;
         BllRack.RackAdd(infoRack);
     }
     catch (Exception ex)
     {
         MessageBox.Show("G3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #34
0
        private static Dictionary <long, string> LoadheatLoadDissipation(ArrayList allRacks, int Power_dissipation_period)
        {
            DateTime now  = DateTime.Now;
            string   str  = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
            string   str2 = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);

            switch (Power_dissipation_period)
            {
            case 0:
                str  = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                str2 = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                break;

            case 1:
                str  = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                str2 = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                break;

            case 2:
            {
                DateTime dateTime = now.AddDays((double)(1 - Convert.ToInt32(now.DayOfWeek.ToString("d"))));
                if (now.DayOfWeek == DayOfWeek.Sunday)
                {
                    dateTime = dateTime.AddDays(-7.0);
                }
                DateTime dateTime2 = dateTime.AddDays(6.0);
                str  = dateTime.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime2.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                str2 = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                break;
            }

            case 3:
            {
                DateTime dateTime  = now.AddDays((double)(1 - now.Day));
                DateTime dateTime2 = dateTime.AddMonths(1).AddDays(-1.0);
                str  = dateTime.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime2.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                str2 = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                break;
            }

            case 4:
            {
                DateTime dateTime  = now.AddMonths(-((now.Month - 1) % 3)).AddDays((double)(1 - now.Day));
                DateTime dateTime2 = dateTime.AddMonths(3).AddDays(-1.0);
                str  = dateTime.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime2.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                str2 = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                break;
            }

            case 5:
            {
                DateTime dateTime  = now.AddDays((double)(1 - Convert.ToInt32(now.DayOfYear.ToString("d"))));
                DateTime dateTime2 = dateTime.AddYears(1).AddDays(-1.0);
                str  = dateTime.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime2.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                str2 = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                break;
            }
            }
            Dictionary <long, string> dictionary = new Dictionary <long, string>();
            Hashtable rackPDSum = DBTools.GetRackPDSum(Power_dissipation_period, allRacks);

            for (int i = 0; i < allRacks.Count; i++)
            {
                double   num      = 0.0;
                bool     flag     = false;
                RackInfo rackInfo = (RackInfo)allRacks[i];
                if (rackPDSum != null && rackPDSum.Count > 0 && rackPDSum.ContainsKey(rackInfo.RackID))
                {
                    flag = true;
                    num  = Convert.ToDouble(rackPDSum[rackInfo.RackID]);
                }
                if (flag)
                {
                    dictionary.Add(rackInfo.RackID, num.ToString());
                }
                else
                {
                    dictionary.Add(rackInfo.RackID, "Error");
                }
            }
            dictionary.Add(0L, str + "#" + str2);
            return(dictionary);
        }
Example #35
0
 private void zonerackInit()
 {
     this.dgvSetDevice               = this.devManFloorGrids1.getRackCtrl();
     this.dgvSetDevice.MultiSelect   = false;
     this.dgvSetDevice.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
     this.dgvSetDevice.DefaultCellStyle.SelectionBackColor = this.Color_DragBlick_rect;
     this.dgvSetDevice.DefaultCellStyle.SelectionForeColor = Color.White;
     this.dgvSetDevice.ShowCellToolTips  = true;
     this.dgvSetDevice.CellMouseClick   -= new DataGridViewCellMouseEventHandler(this.dgvSetDevice_CellMouseClick);
     this.dgvSetDevice.CellMouseClick   += new DataGridViewCellMouseEventHandler(this.dgvSetDevice_CellMouseClick);
     this.dgvSetDevice.SelectionChanged -= new System.EventHandler(this.dgvSetDevice_SelectionChanged);
     this.dgvSetDevice.SelectionChanged += new System.EventHandler(this.dgvSetDevice_SelectionChanged);
     this.dgvSetDevice.MouseDown        -= new MouseEventHandler(this.dgvSetDevice_MouseDown);
     this.dgvSetDevice.MouseDown        += new MouseEventHandler(this.dgvSetDevice_MouseDown);
     this.inSelection             = false;
     this.zonedef_startR          = -1;
     this.zonedef_startC          = -1;
     this.zonedef_endR            = -1;
     this.zonedef_endC            = -1;
     this.dgvSetDevice.MouseMove -= new MouseEventHandler(this.dgvSetDevice_MouseMove);
     this.dgvSetDevice.MouseMove += new MouseEventHandler(this.dgvSetDevice_MouseMove);
     this.dgvSetDevice.MouseUp   -= new MouseEventHandler(this.dgvSetDevice_MouseUP);
     this.dgvSetDevice.MouseUp   += new MouseEventHandler(this.dgvSetDevice_MouseUP);
     System.GC.Collect();
     System.Collections.ArrayList allRack_NoEmpty = RackInfo.GetAllRack_NoEmpty();
     for (int i = 0; i < allRack_NoEmpty.Count; i++)
     {
         RackInfo rackInfo        = (RackInfo)allRack_NoEmpty[i];
         string   displayRackName = rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
         string   tag             = rackInfo.RackID.ToString();
         int      startPoint_X    = rackInfo.StartPoint_X;
         int      startPoint_Y    = rackInfo.StartPoint_Y;
         int      endPoint_X      = rackInfo.EndPoint_X;
         int      arg_1C3_0       = rackInfo.EndPoint_Y;
         string   text;
         if (startPoint_X == endPoint_X)
         {
             text = "H";
         }
         else
         {
             text = "V";
         }
         DataGridViewSpanCell dataGridViewSpanCell = (DataGridViewSpanCell)this.dgvSetDevice.Rows[startPoint_X].Cells[startPoint_Y];
         dataGridViewSpanCell.Tag                = tag;
         dataGridViewSpanCell.Value              = displayRackName;
         dataGridViewSpanCell.BackColor          = this.ColorRack_notinZone;
         dataGridViewSpanCell.SelectionBackColor = this.ColorRack_inZone_Sel;
         if (text.Equals("H"))
         {
             dataGridViewSpanCell.SetColumnSpan(1);
             dataGridViewSpanCell.ToolTipText = displayRackName;
             DataGridViewSpanCell dataGridViewSpanCell2 = (DataGridViewSpanCell)this.dgvSetDevice.Rows[startPoint_X].Cells[startPoint_Y + 1];
             dataGridViewSpanCell2.Tag                = tag;
             dataGridViewSpanCell2.Value              = displayRackName;
             dataGridViewSpanCell2.BackColor          = this.ColorRack_notinZone;
             dataGridViewSpanCell2.SelectionBackColor = this.ColorRack_inZone_Sel;
             dataGridViewSpanCell2.SetColumnSpan(-1);
             dataGridViewSpanCell2.ToolTipText = displayRackName;
         }
         else
         {
             if (text.Equals("V"))
             {
                 dataGridViewSpanCell.SetRowSpan(1);
                 dataGridViewSpanCell.ToolTipText = displayRackName;
                 DataGridViewSpanCell dataGridViewSpanCell3 = (DataGridViewSpanCell)this.dgvSetDevice.Rows[startPoint_X + 1].Cells[startPoint_Y];
                 dataGridViewSpanCell3.Tag                = tag;
                 dataGridViewSpanCell3.Value              = displayRackName;
                 dataGridViewSpanCell3.BackColor          = this.ColorRack_notinZone;
                 dataGridViewSpanCell3.SelectionBackColor = this.ColorRack_inZone_Sel;
                 dataGridViewSpanCell3.SetRowSpan(-1);
                 dataGridViewSpanCell3.ToolTipText = displayRackName;
             }
         }
     }
     this.gridinit(this.dgvSetDevice);
     this.ZoneDisplayAll();
 }
        /// <summary>
        /// Function to edit the existing rack
        /// </summary>
        public void EditFunction()
        {
            try
            {
                RackBll BllRack = new RackBll();
                RackInfo rackInfo = new RackInfo();
                rackInfo.RackName = txtRackName.Text.Trim();
                rackInfo.GodownId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
                rackInfo.Narration = txtNarration.Text.Trim();
                rackInfo.ExtraDate = DateTime.Now;
                rackInfo.Extra1 = string.Empty;
                rackInfo.Extra2 = string.Empty;
                rackInfo.RackId = decRackId;
                if (txtRackName.Text != strRackName)
                {
                    if (CheckExistenceOfRackName() == false)
                    {
                        if (BllRack.RackEdit(rackInfo))
                        {
                            Messages.UpdatedMessage();
                            Clear();
                        }
                    }
                    else
                    {
                        Messages.InformationMessage("Already exists");
                        txtRackName.Focus();
                    }
                }
                else if (rackInfo.RackId == 1)
                {
                    Messages.InformationMessage("Cannot update");
                    Clear();
                    txtRackName.Focus();
                }
                else
                {
                    if (BllRack.RackEdit(rackInfo))
                    {
                        Messages.UpdatedMessage();
                        Clear();

                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("R8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }