//新增压力测试结果
        public JsonResult addScoreResult(string deviceId, string score)
        {
            var res = new JsonResult();

            BLL.User user = new BLL.User();
            bool     flag = user.AddScoreResult(deviceId, score);

            if (flag)
            {
                res.Data = new
                {
                    success = true
                };
            }
            else
            {
                res.Data = new
                {
                    success = false,
                    backMsg = "提交失败,请重试"
                };
            }
            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;//允许使用GET方式获取,否则用GET获取是会报错。

            return(res);
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //测试验证信息
            string userName = textBox1.Text.Trim();
            string password = textBox2.Text.Trim();

            if (userName == "" || password == "")
            {
                MessageBox.Show("用户名或密码不能为空!");
                textBox1.Focus();
                return;
            }
            else
            {
                BLL.User user = new BLL.User();
                if (user.Login(userName, password))
                {
                    UserHelper.userName = textBox1.Text.Trim();
                    UserHelper.password = textBox2.Text.Trim();
                    FormMain f = new FormMain(userName);
                    f.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误,请重新输入!", "错误");
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox1.Focus();
                }
            }
        }
        /// <summary>
        /// Saves the password change.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void xpButton18_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text == txtConfirm.Text)
            {
                var us = new User();
                if (userId != 0)
                {
                    us.LoadByPrimaryKey(userId);
                    if (us.UserName != "admin")
                    {
                        XtraMessageBox.Show("You have no administative privilage to change password!", "Warning");
                        return;
                    }
                    if (us.Password == txtOldPass.Text)
                        {
                            us.Password = txtPassword.Text;
                            us.Save();
                            XtraMessageBox.Show("The password have been changed!", "Succcess");
                        }
                        else
                        {
                            XtraMessageBox.Show("Old Password is not correct!", "Invaild Password", MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                        }

                }
            }
            else
            {
                XtraMessageBox.Show("Password doesnt match!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
 private void SetPermission()
 {
     if (BLL.Settings.UseNewUserManagement)
     {
         if (this.HasPermission("Edit-Financial"))
         {
             InvoiceAccessMode = AccessMode.Finance;
         }
         else
         {
             InvoiceAccessMode = AccessMode.Distribution;
         }
     }
     else
     {
         //Set Access mode
         if (User.GetUserType(CurrentContext.UserId) == UserType.Constants.FUND_OFFICER ||
             User.GetUserType(CurrentContext.UserId) == UserType.Constants.FINANCE)
         {
             InvoiceAccessMode = AccessMode.Finance;
         }
         else
         {
             InvoiceAccessMode = AccessMode.Distribution;
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string password = txtUserPassword.Text.Trim();

            if (userName == "" || password == "")
            {
                MessageBox.Show("用户名或密码不能为空!");
                txtUserName.Focus();
                return;
            }
            else
            {
                BLL.User user = new BLL.User();
                if (user.Login(userName, password))
                {
                    UserHelper.Recorder = user.GetName(userName, password, "Recorder");
                    UserHelper.userName = txtUserName.Text.Trim();
                    UserHelper.password = txtUserPassword.Text.Trim();
                    this.Hide();
                    MainForm f = new MainForm();
                    f.Show();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误,请重新输入!", "错误");
                    txtUserName.Text     = "";
                    txtUserPassword.Text = "";
                    txtUserName.Focus();
                }
            }
        }
        public void ChangeLayoutByMode()
        {
            BLL.User user = new User();
            user.LoadByPrimaryKey(CurrentContext.UserId);
            isConfirmation = false;
            if (isConfirmation)
            {
                layoutControlItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                rgPricingMode.EditValue = "Items";
                btnSetNewPrice.Text = "Confirm";
            }
            else if (BLL.Settings.HandleGRV)
            {
                btnSetNewPrice.Text = "Calculate";
            }
            else
            {
                btnSetNewPrice.Text = "Set";
            }

            if (!BLL.Settings.IsCenter)
            {
                colSellingPrice.Visible = true;
                layoutSellingPrice.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            }
            else
            {
                colSellingPrice.Visible = false;
                layoutSellingPrice.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;

            }
        }
        //新增生活方式评测结果
        public JsonResult addLifeResult(string device_id, string smoke_score, string drink_score, string life_score, string exercise_score, string sleep_score)
        {
            var res = new JsonResult();

            BLL.User user = new BLL.User();
            bool     flag = user.AddLifeResult(device_id, smoke_score, drink_score, life_score, exercise_score, sleep_score);

            if (flag)
            {
                res.Data = new
                {
                    success = true
                };
            }
            else
            {
                res.Data = new
                {
                    success = false,
                    backMsg = "提交失败,请重试"
                };
            }
            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;//允许使用GET方式获取,否则用GET获取是会报错。

            return(res);
        }
Пример #8
0
        private void TxtUsernameKeyDown(object sender, KeyEventArgs e)
        {
            // if this is a debugging session login automattically
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // this has to be removed after development
                if (e.Control && e.Alt)
                {
                    if (txtUsername.Text == "")
                    {
                        txtUsername.Text = "su";
                    }
                    UserInformation userInfo = null;

                    if (BLL.Settings.UseNewUserManagement)
                    {
                        userInfo = Auth.Authenticate(txtUsername.Text);
                        if (userInfo == null)
                        {
                            //errorLogger.SaveError(0, 1, 1, 2, "Login Attempt", "Warehouse", new InvalidCredentialException("Invalid credentials, Username = " + username));
                            //return false;
                        }
                        Thread.CurrentPrincipal = SecurityPrincipal.CreateSecurityPrincipal(userInfo);
                    }

                    User usr = new User();
                    usr.Where.UserName.Value = txtUsername.Text;
                    usr.Query.Load();
                    LogUserIn(usr);
                }
            }
        }
 private void xpButton18_Click(object sender, EventArgs e)
 {
     if (txtPassword.Text == txtConfirm.Text)
     {
         User us = new User();
         if (userId != 0)
         {
             us.LoadByPrimaryKey(userId);
             string userName = us.UserName;
             us.GetUserByAccountInfo(userName, txtOldPass.Text);// .LoadByPrimaryKey(userId);
             if (us.RowCount > 0)
             {
                 if (txtPassword.Text != "")
                 {
                     us.SavePassword(txtPassword.Text);
                 }
                 //us.Password = txtPassword.Text;
                 us.Save();
                 XtraMessageBox.Show(@"Password changed!", @"Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 XtraMessageBox.Show("Old Password is not correct!", "Invaild Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Password doesnt match!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #10
0
        protected void submit_Click(object sender, EventArgs e)
        {
            BLL.User user = BLL.Static.LogIn(userNameTextBox.Text, passTextBox.Text);

            if (user == null)
            {
                check.Visible    = true;
                Session["admin"] = null;
                Session["user"]  = null;
                return;
            }
            if (user.IsAdmin)
            {
                Session["admin"] = user;
                Session.Timeout  = 20;
            }
            if (user.IsBusiness)
            {
                Session["bussiness"] = user;
                Session.Timeout      = 20;
            }
            else
            {
                Session["user"] = user;
                Session.Timeout = 20;
            }
            check.Visible = false;
            Response.Redirect("main.aspx");
        }
 private void ChangePassword_Load(object sender, EventArgs e)
 {
     User us = new User();
     us.LoadByPrimaryKey(userId);
     txtUsername.Text = us.UserName;
     txtUsername.Enabled = false;
 }
Пример #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns>A user if found; null if user not found</returns>
        public User GetUserByName(String name)
        {
            DataSet ds = new DataSet();
            DataSetTableAdapters.usersTableAdapter adapter = new DataSetTableAdapters.usersTableAdapter();
            adapter.Fill(ds.users);
            User u = new User();

            // find the user
            DataSet.usersDataTable table = adapter.GetUserByName(name);

            // if a user was found, then fill in the details
            if (table.Rows.Count > 0)
            {
                // use the 1st row's data
                DataSet.usersRow row = (DataSet.usersRow)table.Rows[0];
                u.Name = row.userName;
                u.Password = row.userPassword;
                u.Email = row.userEmail;
                u.ClientId = row.clientId;
                return u;
            }
            else
            {
                return null;
            }
        }
        //获取最新生活方式评测结果
        public JsonResult getLatestLifeStyleResult(string deviceId, int month)
        {
            var res = new JsonResult();

            BLL.User  user = new BLL.User();
            DataTable dt   = user.GetLatestLifeStyleResult(deviceId, month);

            if (dt.Rows.Count > 0)
            {
                res.Data = new
                {
                    success  = true,
                    backData = CommonTool.JsonHelper.DataTableToJSON(dt)
                };
            }
            else
            {
                res.Data = new
                {
                    success = false,
                    backMsg = "请先进行生活方式评测"
                };
            }
            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;//允许使用GET方式获取,否则用GET获取是会报错。

            return(res);
        }
        private void gridOrderListView_FocusedRowChanged(object sender,
                                                         DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            DataRow dr = gridOrderListView.GetFocusedDataRow();
            if (dr != null)
            {
                int receiptID = Convert.ToInt32(dr["ID"]);
                ReceiveDoc receiveDoc = new ReceiveDoc();
                receiveDoc.LoadAllByReceiptID(receiptID);
                DataTable tbl = receiveDoc.DefaultView.ToTable();
                ReceiveDocDeleted receiveDocDeleted = new ReceiveDocDeleted();
                receiveDocDeleted.LoadAllByReceiptID(receiptID);

                LogReceiptStatus logReceiptStatus = new LogReceiptStatus();
                gridHistory.DataSource = logReceiptStatus.GetLogHistory(receiptID);

                if (receiveDocDeleted.RowCount > 0)
                {
                    tbl.Merge(receiveDocDeleted.DefaultView.ToTable());
                    BLL.User user = new User();
                    user.LoadByPrimaryKey(receiveDocDeleted.DeletedBy);
                    if (user.RowCount > 0)
                    {
                        lblDeletedBy.Text = string.Format("Deleted By {0}",
                                                          string.IsNullOrEmpty(user.FullName)
                                                              ? user.UserName
                                                              : user.FullName);
                    }
                }

                gridOrderDetail.DataSource = tbl;
            }
        }
        //更新用户信息
        public JsonResult updateUserInfo(string deviceId, string fieldName, string fieldValue)
        {
            var res = new JsonResult();

            BLL.User user = new BLL.User();
            bool     flag = user.UpdateUserInfo(deviceId, fieldName, fieldValue);

            if (flag)
            {
                res.Data = new
                {
                    success = true
                };
            }
            else
            {
                res.Data = new
                {
                    success = false,
                    backMsg = "修改失败,请重试"
                };
            }
            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;//允许使用GET方式获取,否则用GET获取是会报错。

            return(res);
        }
 private void registering_Click(object sender, EventArgs e)
 {
     if (UserHelper.Inspecter == "")
     {
         new check_login(this).ShowDialog();
     }
     if (UserHelper.Inspecter != "")
     {
         BLL.User user = new BLL.User();
         string   msg  = "";
         if (user.Register(username.Text, password.Text, check_passwrod.Text, name.Text, phone.Text, occupation.Text, out msg))
         {
             MessageBox.Show("注册成功");
         }
         else
         {
             MessageBox.Show(msg);
         }
     }
 }
        //获取用户信息
        public JsonResult getUserInfo(string deviceId)
        {
            var res = new JsonResult();

            BLL.User  _user = new BLL.User();
            DataTable dt    = _user.getUserInfo(deviceId);

            if (dt.Rows.Count > 0)
            {
                user u = new user();
                u.id          = dt.Rows[0]["id"].ToString();
                u.open_id     = dt.Rows[0]["open_id"].ToString();
                u.name        = dt.Rows[0]["name"].ToString();
                u.age         = Convert.ToInt32(dt.Rows[0]["age"].ToString());
                u.sex         = dt.Rows[0]["sex"].ToString();
                u.telephone   = dt.Rows[0]["telephone"].ToString();
                u.period      = dt.Rows[0]["period"].ToString();
                u.height      = Convert.ToSingle(dt.Rows[0]["height"].ToString());
                u.weight      = Convert.ToSingle(dt.Rows[0]["weight"].ToString());
                u.waistline   = Convert.ToSingle(dt.Rows[0]["waistline"].ToString());
                u.workingType = dt.Rows[0]["workingType"].ToString();

                res.Data = new
                {
                    success  = true,
                    backData = u
                };
            }
            else
            {
                res.Data = new
                {
                    success = false,
                    backMsg = "用户查询失败"
                };
            }
            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;//允许使用GET方式获取,否则用GET获取是会报错。

            return(res);
        }
Пример #18
0
        private void LogUserIn(User us)
        {
            // Now change the connection string to have the user id in the application name...
            ConnectionHelper.CurrentConnection.ApplicationName = string.Format("HCMIS-Warehouse-V-{0}-U-{1}", Program.HCMISVersionString, us.ID);

            // Re-register the connection string manager here.

            MyGeneration.dOOdads.BusinessEntity.RegistryConnectionString = ConnectionHelper.CurrentConnection.ToString();
            ConnectionManager.ConnectionString = ConnectionHelper.CurrentConnection.ToString();

            if (BLL.Settings.UseNewUserManagement)
            {
                // Idealy, this has to work, but we don't know the kind of code that depends on the legacy new main window object.
                var        menuItems  = MenuListViewModel.GenerateMenuForUser(((UserIdentity)Thread.CurrentPrincipal.Identity).UserID);
                MainWindow mainWindow = new MainWindow(menuItems);

                //Legacy Code ... Remove this when not in use.
                CurrentContext main = new CurrentContext();
                CurrentContext.UserId           = us.ID;
                CurrentContext.LoggedInUser     = us;
                CurrentContext.LoggedInUserName = string.Format("{0} {1}", us.FirstName, us.LastName);

                if (string.IsNullOrEmpty(CurrentContext.LoggedInUserName))
                {
                    CurrentContext.LoggedInUserName = us.UserName;
                }

                mainWindow.Show();
                this.Hide();
            }

            if (!System.Diagnostics.Debugger.IsAttached)
            {
                BLL.LogLogin newLoginLog = new LoginLog();
                newLoginLog.AddNew(us.ID, DateTimeHelper.ServerDateTime, true, Environment.MachineName, "", "",
                                   false, "", Program.HCMISVersionString);
                // Also update the last login time on the User Object
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isNew = false;
            if (txtConfirm.Text == txtPassword.Text && cboUserType.SelectedValue != null)
            {
                User us = new User();
                if (userId != 0)
                {
                    us.LoadByPrimaryKey(userId);
                }
                else
                {
                    us.AddNew();
                    isNew = true;
                }

                us.UserName = txtUsername.Text;
                us.FullName = txtFullName.Text;
                us.Address = txtAddress.Text;
                us.Mobile = txtMobile.Text;
                us.Active = ckActive.Checked;
                us.UserType = Convert.ToInt32(cboUserType.SelectedValue);
                us.Save();
                int userID = us.ID;
                // DO MD5
                if (txtPassword.Text != "")
                {
                    us.SavePassword(txtPassword.Text);
                }

                RefreshUserStoreGrid(userID);
                PopulateUser();
                XtraMessageBox.Show("Your changes have been saved!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
                XtraMessageBox.Show("Password doesnt match or you didnt select User Type!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Пример #20
0
        public List<User> GetUsers()
        {
            List<User> users = new List<User>();
            DataSet ds = new DataSet();
            DataSetTableAdapters.usersTableAdapter adapter = new DataSetTableAdapters.usersTableAdapter();
            adapter.Fill(ds.users);
            DataSet.usersDataTable table = adapter.GetUserData();

            // load all users into the list
            foreach (DataSet.usersRow row in table.Rows)
            {
                // create memory for new user & fill in properties
                User u = new User();
                u.Name = row.userName;
                u.Password = row.userPassword;
                u.Email = row.userEmail;
                u.ClientId = row.clientId;

                // add this user to the list
                users.Add(u);
            }
            // returns the list w/ 0 or more Users
            return users;
        }
 /// <summary>
 /// Save user information
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtConfirm.Text == txtPassword.Text)
     {
         User us = new User();
         if (_userId != 0)
             us.LoadByPrimaryKey(_userId);
         else
         {
             us.AddNew();
             us.UserName = txtUsername.Text;
             us.Password = txtPassword.Text;
         }
         us.FullName = txtFullName.Text;
         us.Address = txtAddress.Text;
         us.Mobile = txtMobile.Text;
         us.Active = ckActive.Checked;
         us.UserType = Convert.ToInt32(cboUserType.SelectedValue);
         us.Save();
         PopulateUser();
     }
     else
         XtraMessageBox.Show("Password doesnt match!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
 }
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            var us = new User();
            var userID = MainWindow.LoggedinId;
            us.LoadByPrimaryKey(userID);

            var dr = gridView1.GetFocusedDataRow();

            if (dr == null) return;

            int tranId = Convert.ToInt32(dr["ID"]);
            var rec = new ReceiveDoc();
            rec.LoadByPrimaryKey(tranId);
            var iss = new IssueDoc();
            iss.GetIssueByBatchAndId(rec.ItemID, rec.BatchNo, rec.ID);
            _dtDate.CustomFormat = "MM/dd/yyyy";
            DateTime dtCurrent = ConvertDate.DateConverter(_dtDate.Text);
            if ((rec.Date.Year != dtCurrent.Year && rec.Date.Month < 11) || (iss.RowCount != 0))
            {
                XtraMessageBox.Show("Unable to Delete, This Transaction has been processed. Try Loss and Adjustment.",
                                    "Unable to Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }
            else
            {

                if (
                    XtraMessageBox.Show(
                        "Are You Sure, You want to delete this Transaction? You will not be able to restore this data.",
                        "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    //AddDeletedRecieveDoc(rec);
                    rec.MarkAsDeleted();
                    rec.Save();

                    _dtDate.Value = DateTime.Now;
                    _dtDate.CustomFormat = "MM/dd/yyyy";
                    dtCurrent = ConvertDate.DateConverter(_dtDate.Text);
                    int yr = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1);
                    DateTime dt1 = new DateTime(yr, 11, 1);
                    DateTime dt2 = new DateTime(dtCurrent.Year, dtCurrent.Month, dtCurrent.Day);
                    DataTable dtRec = rec.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), dt1, dt2);
                    gridReceives.DataSource = dtRec;
                }
            }
        }
Пример #23
0
        private void OnApprovedOrderRowClicked(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            if (e != null && e.RowHandle < -1)
            {
                return;
            }

            var gv = (GridView)sender;
            var dr = gv.GetFocusedDataRow();

            _orderID = Convert.ToInt32(dr["ID"].ToString());

            order.LoadByPrimaryKey(_orderID);
            // populate the general order variables
            txtPickListFromStore.Text = order.GetFromStore();
            lblMode.Text = order.GetFromStore() ?? "-";

            txtPickListRequestedBy.Text = order.GetRequestedBy();
            labelControl9.Text          = order.GetRequestedBy() ?? "-";

            var us = new BLL.User();

            us.LoadByPrimaryKey(order.FilledBy);
            lblFilledBy.Text = us.FullName ?? "-";
            string s = "";

            lblLetterNum.Text = String.IsNullOrEmpty(order.LetterNo) ? "-" : order.LetterNo;

            var orderDetail = new OrderDetail();

            orderDetail.LoadAllByOrderID(order.ID);

            var paymentType = new BLL.PaymentType();

            paymentType.LoadByPrimaryKey(order.PaymentTypeID);

            if (!orderDetail.IsColumnNull("StoreID"))
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(orderDetail.StoreID);
                lblMode.Text = activity.ModeName ?? "-";
            }

            lblIssueStatus.Text = (string)dr["OrderStatus"] ?? "-";
            lblIssueType.Text   = (string)dr["Description"] ?? "-";

            if (!order.IsColumnNull("RequestedBy"))
            {
                var ins = new Institution();
                ins.LoadByPrimaryKey(order.RequestedBy);

                var ownership = new BLL.OwnershipType();
                ownership.LoadByPrimaryKey(ins.Ownership);

                int length = ins.Name.Length;
                HeaderSection.Text      = ins.Name + s.PadRight(150 - length) + "Order Number: " + order.RefNo;
                lblOwnership.Text       = ownership.Name ?? "-";
                lblZone.Text            = ins.ZoneName ?? "-";
                lblWoreda.Text          = ins.WoredaName ?? "-";
                lblRegion.Text          = ins.RegionName ?? "-";
                lblInstitutionType.Text = ins.InstitutionTypeName ?? "-";
            }
            else
            {
                HeaderSection.Text = lblOwnership.Text = lblZone.Text = lblWoreda.Text = lblRegion.Text = lblInstitutionType.Text = "-";
            }


            lblPaymentType.Text = paymentType.Name;
            lblOrderDate.Text   = order.Date.ToShortDateString();

            txtPickListOrderNumber.Text = order.RefNo;
            labelControl12.Text         = order.RefNo;

            txtPickListApprovedBy.Text = order.GetApprovedBy();
            labelControl13.Text        = order.GetApprovedBy();

            if (order.OrderStatusID == OrderStatus.Constant.PICK_LIST_GENERATED)
            {
                PickList pl = new PickList();
                gridPickListDetail.DataSource = pl.GetPickListDetailsForOrder(_orderID);

                btnPrintAndSavePickList.Text = @"Confirm";
                colPrice.FieldName           = "Cost";
                colSKU.FieldName             = "Packs";
                btnCancelPickList.Enabled    = (BLL.Settings.UseNewUserManagement)? this.HasPermission("Cancel-Pick-List"):true;

                pl.LoadByOrderID(_orderID);
                if (!pl.IsColumnNull("PickedBy"))
                {
                    us.LoadByPrimaryKey(pl.PickedBy);
                    lblPicklistPrintedBy.Text = us.FullName;
                }
                else
                {
                    lblPicklistPrintedBy.Text = "-";
                }

                lblPicklistPrintedDate.Text = !pl.IsColumnNull("SavedDate") ? pl.SavedDate.ToShortDateString() : "-";
                lblPicklistNo.Text          = !pl.IsColumnNull("PrintedID") ? pl.PrintedID.ToString() : "-";
            }
            //gridPickListView.EndSummaryUpdate();
        }
        /// <summary>
        /// Populates user related info
        /// </summary>
        private void PopulateUser()
        {
            User us = new User();
            DataTable dtUser = us.GetUsers();
            int count = 1;
            int col = 0;
            lstUsers.Items.Clear();
            foreach (DataRow dv in dtUser.Rows)
            {
                string[] str = { count.ToString(), dv["FullName"].ToString(), dv["Mobile"].ToString(), dv["UserName"].ToString(), dv["Type"].ToString() };
                ListViewItem lst = new ListViewItem(str) {Tag = dv["ID"]};
                if (col != 0)
                {
                    lst.BackColor = Color.FromArgb(233, 247, 248);
                    col = 0;
                }
                else
                    col++;
                lstUsers.Items.Add(lst);
                count++;
            }

            UserType uType = new UserType();
            uType.LoadAll();
            cboUserType.DataSource = uType.DefaultView;
        }
        private void gridUserView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            DataRow dr = gridUserView.GetFocusedDataRow();

            if (dr != null)
            {
                int selected = Convert.ToInt32(dr["ID"]);
                User us = new User();
                us.LoadByPrimaryKey(selected);
                txtFullName.Text = us.FullName;
                txtAddress.Text = us.Address;
                txtMobile.Text = us.Mobile;
                ckActive.Checked = us.Active;
                cboUserType.SelectedValue = us.UserType.ToString();
                txtUsername.Text = us.UserName;

                userId = us.ID;
                RefreshUserStoreGrid(us.ID);
                RefreshUserPhysicalStoreGrid(us.ID);
            }
        }
Пример #26
0
        private void OnApprovedOrderRowClicked(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            var gv = (GridView)sender;
            var dr = gv.GetFocusedDataRow();
            var or = new BLL.Order();

            _orderID = Convert.ToInt32(gv.GetFocusedDataRow()["ID"].ToString());

            order.LoadByPrimaryKey(_orderID);
            // populate the general order variables
            txtPickListFromStore.Text = order.GetFromStore();
            lblMode.Text = order.GetFromStore();

            txtPickListRequestedBy.Text = order.GetFilledBy();

            if (!order.IsColumnNull("RequestedBy"))
            {
                var ins = new Institution();
                ins.LoadByPrimaryKey(order.RequestedBy);

                var ownership = new BLL.OwnershipType();
                ownership.LoadByPrimaryKey(ins.Ownership);

                lblOwnership.Text       = ownership.Name;
                lblInstitutionType.Text = ins.InstitutionTypeName;
                lblFacility.Text        = ins.Name;
                lblWoreda.Text          = ins.WoredaName;
                lblZone.Text            = ins.ZoneName;
                lblRegion.Text          = ins.RegionName;
                lblLetterNum.Text       = String.IsNullOrEmpty(order.LetterNo) ? "-" : order.LetterNo;
            }
            else
            {
                lblFacility.Text = lblWoreda.Text = lblZone.Text = lblRegion.Text = lblOwnership.Text = "";// lblType.Text = "";
            }

            int length = order.GetRequestedBy().Length;


            string s = "";

            HeaderLayoutGroup.Text = order.GetRequestedBy() + s.PadRight(150 - length) + "Order Number:" + order.RefNo;

            txtPickListOrderNumber.Text = order.RefNo;
            lblOrderNum.Text            = order.RefNo;

            txtPickListApprovedBy.Text = order.GetApprovedBy();
            lblApprovedBy.Text         = order.GetApprovedBy();

            var orderDetail = new OrderDetail();

            orderDetail.LoadAllByOrderID(order.ID);

            if (!orderDetail.IsColumnNull("StoreID"))
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(orderDetail.StoreID);
                lblMode.Text = activity.ModeName;
            }

            lblOrderDate.Text = order.Date.ToShortDateString();

            var us = new BLL.User();

            us.LoadByPrimaryKey(order.FilledBy);
            lblFilledBy.Text = us.FirstName;


            lblIssueStatus.Text = (string)dr["OrderStatus"] ?? "-";
            lblIssueType.Text   = (string)dr["Description"] ?? "-";

            var paymentType = new BLL.PaymentType();

            paymentType.LoadByPrimaryKey(order.PaymentTypeID);
            lblPaymentType.Text = paymentType.Name;

            if (order.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED)
            {
                progressBarControl.Properties.Maximum = order.CountOfDetailItems();
                progressBarControl.Properties.DisplayFormat.FormatString = "{0: #,##0}" + string.Format(" of {0}", progressBarControl.Properties.Maximum);
                progressBarControl.Properties.DisplayFormat.FormatType   = FormatType.Custom;
                progressBarControl.EditValue = 0;
                this.Enabled = false;
                progressBarControl.Visible = true;
                bgWorker.RunWorkerAsync(_orderID);
            }
        }
        public List<Order> GetStandardRRFOrders()
        {
            var client = new ServiceRRFLookupClient();
            var orders = new List<Order>();
            var ginfo = new GeneralInfo();
            ginfo.LoadAll();

            var dataView = gridItemChoiceView.DataSource as DataView;
            if (dataView != null)
            {
                dataView.RowFilter = gridItemChoiceView.ActiveFilterString;
                tblRRF = dataView.ToTable();
            }

            var periods = client.GetCurrentReportingPeriod(ginfo.FacilityID, ginfo.ScmsWSUserName, ginfo.ScmsWSPassword);
            var form = client.GetForms(ginfo.FacilityID, ginfo.ScmsWSUserName, ginfo.ScmsWSPassword);

            var rrfs = client.GetFacilityRRForm(ginfo.FacilityID, form[0].Id, periods[0].Id, 1, ginfo.ScmsWSUserName, ginfo.ScmsWSPassword);
            var formCategories = rrfs.First().FormCategories;
            var chosenCategoryBody = formCategories.First(x => x.Id == 1); //TODO:Hard coding to be removed.
            var items = chosenCategoryBody.Pharmaceuticals;

            var user = new User();
            user.LoadByPrimaryKey(MainWindow.LoggedinId);

            var order = new Order
                            {
                                RequestCompletedDate = DateTime.Now,
                                OrderCompletedBy = user.FullName,
                                RequestVerifiedDate = DateTime.Now,
                                OrderTypeId = STANDARD_ORDER,
                                SubmittedBy = user.FullName,
                                SubmittedDate = DateTime.Now,
                                SupplyChainUnitId = ginfo.FacilityID,
                                OrderStatus = 1, //TODO: hardcoding
                                FormId = form[0].Id, //TODO: hardcoding
                                ReportingPeriodId = periods[0].Id //TODO: hardcoding
                            };

            var details = new List<RRFTransactionService.OrderDetail>();

            foreach (DataRow rrfLine in tblRRF.Rows)
            {
                var detail = new RRFTransactionService.OrderDetail();
                var hcmisItemID = Convert.ToInt32(rrfLine["DSItemID"]);
                var rrFormPharmaceutical = items.SingleOrDefault(x => x.PharmaceuticalId == hcmisItemID);
                if (rrFormPharmaceutical != null && Convert.ToString(rrfLine["Status"]) != "Below EOP")
                {
                        detail.BeginningBalance = Convert.ToInt32(rrfLine["BeginingBalance"]);
                        detail.EndingBalance = Convert.ToInt32(rrfLine["SOH"]);
                        detail.QuantityReceived = Convert.ToInt32(rrfLine["Received"]);
                        detail.QuantityOrdered = Convert.ToInt32(rrfLine["Quantity"]);
                        detail.LossAdjustment = Convert.ToInt32(rrfLine["LossAdj"]);
                        detail.ItemId = rrFormPharmaceutical.ItemId;
                        var rdDoc = new ReceiveDoc();
                        var disposal = new Disposal();

                        rdDoc.GetAllWithQuantityLeft(hcmisItemID, _storeID);
                        disposal.GetLossAdjustmentsForLastRrfPeriod(hcmisItemID, _storeID, periods[0].StartDate,
                                                                    periods[0].EndDate);
                        int receiveDocEntries = rdDoc.RowCount;
                        int disposalEntries = disposal.RowCount;

                        if (rdDoc.RowCount == 0 && detail.EndingBalance == 0)
                            detail.Expiries = null;

                        detail.Expiries = new Expiry[receiveDocEntries];
                        detail.Adjustments = new Adjustment[disposalEntries];

                        rdDoc.Rewind();
                        int expiryAmountTotal = 0;

                        for (int j = 0; j < receiveDocEntries; j++)
                        {
                            var exp = new Expiry
                                          {
                                              Amount = Convert.ToInt32(rdDoc.QuantityLeft)
                                          };
                            expiryAmountTotal += exp.Amount;

                            exp.BatchNo = rdDoc.BatchNo;
                            exp.ExpiryDate = rdDoc.ExpDate;
                            if(exp.ExpiryDate > periods[0].EndDate.AddDays(ExpiryTreshHold))
                                exp.Amount = Convert.ToInt32(rdDoc.QuantityLeft);
                                exp.ExpiryDate = periods[0].EndDate;
                            detail.Expiries[j] = exp;
                            rdDoc.MoveNext();
                        }

                        disposal.Rewind();

                        int lossadjamt = 0;
                        for (int j = 0; j < disposalEntries; j++)
                        {
                            var adj = new Adjustment
                            {
                                Amount = Convert.ToInt32(disposal.Quantity),
                                TypeId = 1,
                                ReasonId = 1
                            };
                            lossadjamt += adj.Amount;

                            if (lossadjamt >= detail.LossAdjustment)
                                detail.LossAdjustment = lossadjamt;

                            detail.Adjustments[j] = adj;
                            disposal.MoveNext();
                        }

                        var stockoutIndexedLists = StockoutIndexBuilder.Builder.GetStockOutHistory(hcmisItemID, _storeID);
                        var DOSPerStockOut = stockoutIndexedLists.Count();
                        detail.DaysOutOfStocks = new DaysOutOfStock[stockoutIndexedLists.Count()];

                        for (int j = 0; j < stockoutIndexedLists.Count(); j++)
                        {
                            var dos = new DaysOutOfStock
                                          {
                                              NumberOfDaysOutOfStock = 5,
                                              StockOutReasonId = 5
                                          };
                            detail.DaysOutOfStocks[j] = dos;
                        }
                }
                else if(rrFormPharmaceutical != null && Convert.ToString(rrfLine["Status"]) == "Below EOP")
                {
                        detail.BeginningBalance = null;
                        detail.EndingBalance = null;
                        detail.QuantityReceived = null;
                        detail.QuantityOrdered = null;
                        detail.LossAdjustment = null;
                        detail.ItemId = rrFormPharmaceutical.ItemId;

                        var rdDoc = new ReceiveDoc();
                        var disposal = new Disposal();
                        rdDoc.GetAllWithQuantityLeft(hcmisItemID, _storeID);
                        disposal.GetLossAdjustmentsForLastRrfPeriod(hcmisItemID, _storeID, periods[0].StartDate,periods[0].EndDate);

                        int receiveDocEntries = rdDoc.RowCount;
                        int disposalEntries = disposal.RowCount;

                        if (rdDoc.RowCount == 0 && detail.EndingBalance == 0)
                            detail.Expiries = null;

                        detail.Expiries = new Expiry[receiveDocEntries];
                        detail.Adjustments = new Adjustment[disposalEntries];

                        rdDoc.Rewind();
                        int expiryAmountTotal = 0;
                        for (int j = 0; j < receiveDocEntries; j++)
                        {
                            var exp = new Expiry {Amount = Convert.ToInt32(rdDoc.QuantityLeft)};
                            expiryAmountTotal += exp.Amount;

                            exp.BatchNo = rdDoc.BatchNo;
                            exp.ExpiryDate = rdDoc.ExpDate;
                            if (expiryAmountTotal >= detail.EndingBalance)
                                if (detail.EndingBalance != null)
                                    exp.Amount = exp.Amount - (expiryAmountTotal - detail.EndingBalance.Value);
                            detail.Expiries[j] = null;
                            rdDoc.MoveNext();
                        }

                        disposal.Rewind();

                        int lossadjamt = 0;
                        for (int j = 0; j < disposalEntries; j++)
                        {
                            var adj = new Adjustment
                            {
                                Amount = Convert.ToInt32(disposal.Quantity),
                                TypeId = 11,
                                ReasonId = 39
                            };
                            lossadjamt += adj.Amount;

                            if (lossadjamt >= detail.LossAdjustment)
                                detail.LossAdjustment = lossadjamt;

                            detail.Adjustments[j] = null;
                            disposal.MoveNext();
                        }

                        var stockoutIndexedLists = StockoutIndexBuilder.Builder.GetStockOutHistory(hcmisItemID, _storeID);
                        var DOSPerStockOut = stockoutIndexedLists.Count();
                        detail.DaysOutOfStocks = new DaysOutOfStock[stockoutIndexedLists.Count()];

                        for (int j = 0; j < stockoutIndexedLists.Count(); j++)
                        {
                            var dos = new DaysOutOfStock();
                            dos.NumberOfDaysOutOfStock = 5;
                            dos.StockOutReasonId = 5;
                            detail.DaysOutOfStocks[j] = null;
                        }
                 }
                details.Add(detail);
            }
            order.OrderDetails = details.ToArray();
            orders.Add(order);
            // loop through each record and create order & order details objects
            return orders;
        }
        private void gridOrderView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (e != null && e.PrevFocusedRowHandle < -1)
             return;

            if (gridOrderView.GetFocusedDataRow() != null)
            {
                var dr = gridOrderView.GetFocusedDataRow();

                int OrderID = Convert.ToInt32(dr["ID"]);
                string sharps = Helpers.FormattingHelpers.GetNumberFormatting();
                Order = new PO(OrderID);
                RefreshInvoice();
                RefreshPoDetail();
                // Layout  ... Show the damn correct layout

                // Hide the empty layout
                LayoutEmptyDetails.Visibility = LayoutVisibility.Never;
                LayoutSelectedOrderDetail.Visibility = LayoutVisibility.Always;

                int Currency = 0x0409;
                if(!Order.IsColumnNull("LCID"))
                    Currency = Order.LCID;

                if(!string.IsNullOrEmpty(Order.s_PurchaseType))
                    PurchaseTypes = POType.GetAllPOTypes().Find(t => t.ID == Order.PurchaseType);
                string space = "";
                DataRow dar = gridInvoiceView.GetFocusedDataRow();
                HeaderGroup.Text = "PO No: " + dr["OrderNumber"].ToString();
               if (dar != null)
               {
                   HeaderGroup.Text = HeaderGroup.Text + space.PadRight(160) + "Invoice No: " + gridInvoiceView.GetFocusedDataRow()["STVOrInvoiceNo"];
               }

              // lblOrderType.Text = PurchaseTypes != null ?  string.Format("{0} : {1}" ,PurchaseTypes.Group , PurchaseTypes.Name) : "";
                lblPONumber.Text = Order.PONumber;
                lblTotalValue.Text = Order.TotalValue.ToString(Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Currency));
                lblInsurance.Text = Order.Insurance.ToString(Helpers.FormattingHelpers.GetBirrFormatting());
                lblNBE.Text = Order.NBE.ToString(Helpers.FormattingHelpers.GetBirrFormatting());
                lblSupplier.Text = Order.Supplier.CompanyName;
                lblShipper.Text = String.IsNullOrEmpty(Order.ShippingSite) ? "-" : Order.ShippingSite;
                lblLetterNo.Text = String.IsNullOrEmpty(Order.LetterNo) ? "-" : Order.LetterNo;
                lblPOType.Text = dr["Name"].ToString();

                var PaymentType = new PaymentType();
                PaymentType.LoadByPrimaryKey(Order.PaymentTypeID);
                lblPaymentType.Text = String.IsNullOrEmpty(PaymentType.Name) ? "-" : PaymentType.Name ;

                var User = new User();
                User.LoadByPrimaryKey(Order.SavedbyUserID);
                lblPOBy.Text = String.IsNullOrEmpty(User.FullName) ? "-" : User.FullName;

                if (!Order.IsColumnNull("ModeID"))
                {
                    var Mode = new Mode();
                    Mode.LoadByPrimaryKey(Order.ModeID);
                    lblMode.Text = Mode.TypeName;
                }
                else lblMode.Text = "-";

                if (!Order.IsColumnNull("PurchaseOrderStatusID"))
                {
                    var poStatus = new PurchaseOrderStatus();
                    poStatus.LoadByPrimaryKey(Order.PurchaseOrderStatusID);
                    lblPOStatus.Text = poStatus.Name;
                }

                chkboxIsElectronic.Checked = Order.IsElectronic;
                lblOrderDate.Text = Order.PODate.ToShortDateString();
                lblSyncDate.Text = Order.ModifiedDate == DateTime.MinValue ? "NA" :  Order.ModifiedDate.ToString(CultureInfo.InvariantCulture);

                if (!Order.IsColumnNull("StoreID"))
                {
                    Activity act = new Activity();
                    act.LoadByPrimaryKey(Order.StoreID);
                    lblAccount.Text = act.AccountName;
                    lblSubAccount.Text = act.SubAccountName;
                    lblActivity.Text = act.Name;

                }
                else
                {
                    lblAccount.Text = lblSubAccount.Text = lblActivity.Text = "-";
                }

                lblRefNo.Text = String.IsNullOrEmpty(Order.RefNo) ? "-" : Order.RefNo;
              lblRemainingValue.Text = Order.Remaining.ToString(Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Currency));
                if (BLL.Settings.UseNewUserManagement && this.HasPermission("Add-Invoice"))
                {
                    btnAddInvoice.Enabled = true;
                }
                else if (BLL.Settings.UseNewUserManagement)
                {
                    btnAddInvoice.Enabled = false;
                }

                btnAddInvoice.Enabled = btnEditOrder.Enabled =btnAddOrderDetail.Enabled = !Order.IsElectronic;

                if (Order.IsElectronic)
                {
                    grdPoDetail.Enabled = false;
                    gridInvoice.Enabled = false;
                }
                else
                {
                    grdPoDetail.Enabled = true ;
                    gridInvoice.Enabled = true;
                }

                //purchse order details
                grdPoDetail.DataSource = Order.PurchaseOrderDetail.DefaultView;
            }
            else
            {
                // Hide the empty layout
                LayoutEmptyDetails.Visibility = LayoutVisibility.Always;
                LayoutSelectedOrderDetail.Visibility = LayoutVisibility.Never;
            }
        }
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            int userID = Convert.ToInt32(e.Argument);
            BLL.User user = new User();
            user.LoadByPrimaryKey(userID);
            try
            {

                HelperClasses.DirectoryServices.RefreshFromDirectoryServices();
                BLL.GeneralInfo info = new GeneralInfo();
                info.LoadAll();
                info.LastSync = DateTime.Now;
                info.Save();
                e.Result = "Completed!";
            }
            catch (Exception ex)
            {
                if (user.UserType != UserType.Constants.SYSTEM_ADMIN)
                    e.Result =
                        "There has been a network error.  The database is not in sync with directory services.  Please connect to the Internet and try again.";
                else
                    e.Result = ex.Message;
            }
        }
        /// <summary>
        /// Populate the lookups and item lists.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ReceiveingForm_Load(object sender, EventArgs e)
        {
            //gridRecieveView.Columns[4].Visible = VisibilitySetting.HandleUnits;
            var UnitColumn = ((GridView)receivingGrid.MainView).Columns[12];
            var UnitColumn1 = ((GridView)receivingGrid.MainView).Columns[5];
            var UnitColumn2 = ((GridView)gridItemsChoice.MainView).Columns[4];
            var qtyperpack = ((GridView)receivingGrid.MainView).Columns[3];
            var buqty = ((GridView)receivingGrid.MainView).Columns[4];
            switch (VisibilitySetting.HandleUnits)
            {
                case 3:
                    UnitColumn.Visible = true;
                    UnitColumn1.Visible = false;
                    UnitColumn2.Visible = false;
                    qtyperpack.Visible = false;
                    buqty.Visible = false;
                    break;
                case 2:
                    UnitColumn.Visible = true;
                    UnitColumn1.Visible = false;
                    UnitColumn2.Visible = false;
                    qtyperpack.Visible = false;
                    buqty.Visible = false;
                    break;
                case 1:
                    UnitColumn.Visible = false;
                    UnitColumn1.Visible = true;
                    qtyperpack.Visible = true;
                    UnitColumn2.Visible = true;
                    buqty.Visible = true;
                    break;
            }

            var stor = new Stores();
            stor.GetActiveStores();

            cboStores.Properties.DataSource = stor.DefaultView;
            cboStores.ItemIndex = 0;

            Programs prog = new Programs();
            DataTable dtProg = prog.GetSubPrograms();
            cboProgram.Properties.DataSource = dtProg;
            cboProgram.Properties.DisplayMember = "Name";
            cboProgram.Properties.ValueMember = "ID";

            var unit = new ItemUnit();
            var units = unit.GetAllUnits();
            UnitsbindingSource.DataSource = units.DefaultView;

            Supplier sup = new Supplier();
            DataTable dtSup = new DataTable();
            sup.GetActiveSuppliers();
            dtSup = sup.DefaultView.ToTable();
            cboSuppliers.DataSource = dtSup;
            cboSupplier.Properties.DataSource = sup.DefaultView;
            cboSuppliers.Text = "Select Supplier";
            cboSuppliers.ValueMember = "ID";
            cboSuppliers.DisplayMember = "CompanyName";

            // Bind the grid with only active items
            Items itm = new Items();
            //DataTable dtItem = itm.GetAllItems(1);
            DataTable dtItem = BLL.Items.GetActiveItemsByCommodityType(0);
            lkCategories.Properties.DataSource = BLL.Type.GetAllTypes();
            lkCategories.ItemIndex = 0;

            PopulateItemList(dtItem);
            selectedType = radioGroup1.EditValue.ToString();
            PopulateCatTree(selectedType);

            int userID = MainWindow.LoggedinId;
            User us = new User();
            us.LoadByPrimaryKey(userID);
            txtReceivedBy.Text = us.FullName;

            // bind the current date as the datetime field
            dtRecDate.Value = DateTime.Now;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var rec = new ReceiveDoc();

            var itm = new Items();
            var itemprogram = new ProgramProduct();
            string valid = ValidateFields();
            if (valid == "true")
            {
                if (
                    XtraMessageBox.Show("Are you sure you want to save this transaction?", "Confirmation",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        for (int i = 0; i < dtRecGrid.Rows.Count; i++)
                        {
                            if (dtRecGrid.Rows[i]["Expiry Date"] != DBNull.Value)
                            {
                                if (Convert.ToDateTime(dtRecGrid.Rows[i]["Expiry Date"]) <= DateTime.Now)
                                {
                                    var dialog =
                                        XtraMessageBox.Show(
                                            "The item " + dtRecGrid.Rows[i]["Item Name"].ToString() +
                                            " has already expired.  Are you sure you want to receive it?", "Warning",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                    if (dialog == DialogResult.No)
                                    {
                                        return;
                                    }

                                }
                            }
                            rec.AddNew();
                            rec.StoreID = Convert.ToInt32(cboStores.EditValue);
                            rec.RefNo = txtRefNo.Text.Trim();
                            rec.Remark = txtRemark.Text;
                            rec.ReceivedBy = txtReceivedBy.Text;

                            DateTime xx = dtRecDate.Value;
                            dtRecDate.CustomFormat = "MM/dd/yyyy";
                            DateTime dtRec = new DateTime();
                            rec.Date = ConvertDate.DateConverter(dtRecDate.Text);

                            dtRec = ConvertDate.DateConverter(dtRecDate.Text);
                            dtRecDate.IsGregorianCurrentCalendar = true;

                            rec.EurDate = dtRecDate.Value;

                            dtRecDate.IsGregorianCurrentCalendar = false;

                            rec.ItemID = Convert.ToInt32(dtRecGrid.Rows[i][0]);

                            switch (VisibilitySetting.HandleUnits)
                            {
                                case 1:
                                    rec.UnitID = 0;
                                    rec.QtyPerPack = Convert.ToInt32(dtRecGrid.Rows[i]["Qty/Pack"]);
                                    break;
                                case 2:
                                    rec.UnitID = Convert.ToInt32(dtRecGrid.Rows[i]["UnitID"]);
                                    rec.QtyPerPack = 1;
                                    break;
                                case 3:
                                    rec.UnitID = Convert.ToInt32(dtRecGrid.Rows[i]["UnitID"]);
                                    rec.QtyPerPack = 1;
                                    break;
                            }
                            rec.NoOfPack = Convert.ToInt32(dtRecGrid.Rows[i]["Pack Qty"]);

                            rec.Quantity = rec.NoOfPack * rec.QtyPerPack;
                            rec.QuantityLeft = rec.Quantity;
                            if (dtRecGrid.Rows[i]["Price/Pack"] != null &&
                                dtRecGrid.Rows[i]["Price/Pack"].ToString() != "")
                            {
                                double pre = Convert.ToDouble(dtRecGrid.Rows[i]["Price/Pack"]) / rec.QtyPerPack;
                                rec.Cost = Convert.ToDouble(pre);
                            }
                            else
                            {
                                rec.Cost = 0;
                            }
                            itm.LoadByPrimaryKey(Convert.ToInt32(dtRecGrid.Rows[i]["ID"]));
                            rec.BatchNo = dtRecGrid.Rows[i][8].ToString();
                            if (dtRecGrid.Rows[i]["Expiry Date"] != DBNull.Value)
                            {
                                rec.ExpDate = Convert.ToDateTime(dtRecGrid.Rows[i]["Expiry Date"]);
                            }

                            rec.SupplierID = Convert.ToInt32(cboSupplier.EditValue);
                            rec.SubProgramID = Convert.ToInt32(cboProgram.EditValue);
                            string batch = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() +
                                           DateTime.Now.Minute.ToString() + rec.ItemID.ToString();
                            rec.LocalBatchNo = batch;

                            rec.Out = false;
                            rec.IsApproved = false;
                            dtRecDate.Value = xx;
                            rec.Save();

                            //check if there is any data on stockoutLog about this item on this store
                            //and update its enddate to today
                            StockoutLog stockoutLog = new StockoutLog();
                            DataTable tblStockoutLog = stockoutLog.LoadByStoreAndItemId(rec.ItemID, rec.StoreID, true);
                            if (tblStockoutLog != null)
                            {
                                if (tblStockoutLog.Rows.Count > 0)
                                {
                                    stockoutLog.LoadByPrimaryKey(int.Parse(tblStockoutLog.Rows[0]["ID"].ToString()));
                                    stockoutLog.EndDate = DateTime.Today;
                                    stockoutLog.Save();
                                }
                            }

                            itemprogram.LoadByOldProgramIdAndItemId(Convert.ToInt32(dtRecGrid.Rows[i][0]),
                                                                 Convert.ToInt32(cboProgram.EditValue));
                            if (itemprogram.RowCount != 0)
                            {
                                continue;
                            }
                            else
                            {
                                itemprogram.AddNew();
                                itemprogram.ItemID = Convert.ToInt32(dtRecGrid.Rows[i][0]);
                                itemprogram.ProgramID = Convert.ToInt32(cboProgram.EditValue);
                                itemprogram.Save();
                            }
                        }
                        XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        ResetFields();
                        //  mgr.CommitTransaction();

                    }
                    catch (Exception exp)
                    {
                        //mgr.RollbackTransaction();
                        BLL.User user = new User();
                        user.LoadByPrimaryKey(MainWindow.LoggedinId);
                        if (user.UserType == UserType.Constants.SYSTEM_ADMIN)
                            XtraMessageBox.Show(exp.Message);
                        else
                            XtraMessageBox.Show("Saving Error!", "Error", MessageBoxButtons.OK);
                    }
                }

            }
            else
            {
                XtraMessageBox.Show(valid, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
        private void LayoutByAccessMode()
        {
            User user = new User();

            user.LoadByPrimaryKey(CurrentContext.UserId);
        }
        private void gridMasterView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (lkWarehouse.EditValue != null && lkAccount.EditValue != null)
            {
                double NewUnitCost;
                double Margin;
                string ReceiveDocIDs;
                DataRow Masterdr = gridMasterView.GetFocusedDataRow();
                if (gridMasterView.GetFocusedRow() != null)
                {

                    if (Masterdr["PricePerPack"] != DBNull.Value)
                    {
                        Masterdr.ClearErrors();
                        if (Convert.ToDouble(Masterdr["PricePerPack"]) < 0)
                        {
                            Masterdr.SetColumnError("PricePerPack","Negative value is not allowed");
                            Masterdr["PricePerPack"] = DBNull.Value;
                            return;
                        }

                        Masterdr["TotalReceived"] = Convert.ToDouble(Masterdr["NoOfPack"]) * Convert.ToDouble(Masterdr["PricePerPack"]);
                        NewUnitCost = Math.Round(Convert.ToDouble(Masterdr["PricePerPack"]),2);
                        ReceiveDocIDs = Masterdr["ReceiveDocIDs"].ToString();
                        Margin = Masterdr["Margin"] != DBNull.Value ? Math.Round(Convert.ToDouble(Masterdr["Margin"])/100, 4) : 0;
                        User user = new User();
                        user.LoadByPrimaryKey(CurrentContext.UserId);
                        BLL.ReceiveDoc.SetBegginingBalanceCostByReceiveDocIDs(NewUnitCost,Margin, ReceiveDocIDs, user.ID, "Beginning Inventory");
                        BLL.ReceiveDoc.SetUnitCostByReceivedocIDs(NewUnitCost,ReceiveDocIDs,user.ID,"Beginning Inventory");
                    }
                    else
                    {
                        Masterdr["TotalReceived"] = DBNull.Value;
                    }
                }

            }
        }
Пример #34
0
        private void BtnLoginClick(object sender, EventArgs e)
        {
            UserInformation userInfo = null;

            try
            {
                if (BLL.Settings.UseNewUserManagement)
                {
                    userInfo = Auth.Authenticate(txtUsername.Text, txtPassword.Text);
                    if (userInfo == null)
                    {
                        //errorLogger.SaveError(0, 1, 1, 2, "Login Attempt", "Warehouse", new InvalidCredentialException("Invalid credentials, Username = "******"", "", true, txtUsername.Text, Program.HCMISVersionString);
                    if (XtraMessageBox.Show(@"Invalid Username or Password!", @"Login Failed", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop) == DialogResult.Cancel)
                    {
                        Application.Exit();
                    }
                    else
                    {
                    }
                }
            }
            catch
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    //ConnectionStringManager.ConnectionStringManager connMgr =
                    //    new ConnectionStringManager.ConnectionStringManager(Program.RegKey,
                    //                                                        Program.PrevConnectionStringKey);
                    //connMgr.ShowDialog();
                }
                else
                {
                    XtraMessageBox.Show("Network error.  Please make sure your network connection is working.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // Clear the login form
            txtPassword.Text = "";
            txtUsername.Text = "";
            txtUsername.Focus();
        }
Пример #35
0
        private void OnUndispatchedIssueClicked(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            var dr = gridUndispatchedIssuesView.GetFocusedDataRow();

            _activeSTVID = Convert.ToInt32(dr["STVID"]);
            gridUndispatchedIssueDetails.DataSource = BLL.Issue.GetIssueDetails(_activeSTVID);


            User usr = new User();

            //usr.LoadByPrimaryKey(NewMainWindow.UserId);
            usr = CurrentContext.LoggedInUser;
            BLL.Issue stv = new BLL.Issue();
            stv.LoadByPrimaryKey(_activeSTVID);

            var activity = new Activity();

            activity.LoadByPrimaryKey(stv.StoreID);
            lblMode.Text = activity.ModeName ?? "-";

            lblAccount.Text = activity.AccountName ?? "-";

            lblActivity.Text   = activity.FullActivityName ?? "-";
            lblSubAccount.Text = activity.SubAccountName ?? "-";

            lblIssueStatus.Text = (string)dr["OrderStatus"] ?? "-";
            lblIssueType.Text   = (string)dr["OrderType"] ?? "-";


            if (!stv.IsColumnNull("ReceivingUnitID"))
            {
                var institution = new Institution();
                institution.LoadByPrimaryKey(stv.ReceivingUnitID);

                var ownership = new BLL.OwnershipType();
                ownership.LoadByPrimaryKey(institution.Ownership);

                lblRegion.Text = institution.RegionName ?? "-";
                lblZone.Text   = institution.ZoneName ?? "-";
                lblWoreda.Text = institution.WoredaName ?? "-";
                var space  = "";
                int length = (institution.Name).Length;
                if (stv.IsColumnNull("IsReprintOf"))
                {
                    FacilityGroup.Text = institution.Name ?? "" + space.PadRight(180 - length) + "Invoice No: " + stv.IDPrinted.ToString("00000");
                }

                lblInstitutionType.Text = institution.InstitutionTypeName;
                lblOwnership.Text       = ownership.Name;
            }
            else
            {
                lblRegion.Text          =
                    lblZone.Text        = lblWoreda.Text = "NA";
                lblInstitutionType.Text = lblOwnership.Text = "-";
                FacilityGroup.Text      = "";
            }

            if (!stv.IsColumnNull("PaymentTypeID"))
            {
                var paymentType = new BLL.PaymentType();
                paymentType.LoadByPrimaryKey(stv.PaymentTypeID);
                lblPaymentType.Text = paymentType.Name;
            }
            else
            {
                lblPaymentType.Text = "-";
            }

            if (!stv.IsColumnNull("DocumentTypeID"))
            {
                lblDocumentedType.Text = DocumentType.GetDocumentType(stv.DocumentTypeID).Name;
            }
            else
            {
                lblDocumentedType.Text = "-";
            }

            lblRequistedDate.Text = dr["VoidRequestDateTime"] == DBNull.Value
                ? "NA"
                : DateTime.Parse(dr["VoidRequestDateTime"].ToString()).ToShortDateString();

            lblVoidRequestedBy.Text = dr["VoidRequestedBy"] == DBNull.Value ? "NA" : (string)dr["VoidRequestedBy"];



            var user = new BLL.User();

            if (dr["VoidApprovedByUserID"] != DBNull.Value)
            {
                user.LoadByPrimaryKey(Convert.ToInt32(dr["VoidApprovedByUserID"]));
                lblVoidConfirmedBy.Text = user.FullName;
            }
            else
            {
                lblVoidConfirmedBy.Text = "NA";
            }


            lblVoidConfirmedDate.Text = dr["VoidApprovalDateTime"] == DBNull.Value
                ? "NA"
                : DateTime.Parse(dr["VoidApprovalDateTime"].ToString()).ToShortDateString();



            stv.LoadLatestReprint();
            txtIssuedBy.Text            = usr.FullName ?? "-";
            lblDispatchConfirmedBy.Text = usr.FullName ?? "-";

            // txtSTVInvoiceNo.Text = stv.IDPrinted.ToString("00000");
            lblSTVNo.Text   = stv.IDPrinted.ToString("00000") ?? "-";
            lblSTVDate.Text = stv.PrintedDate.ToShortDateString() ?? "-";


            user.LoadByPrimaryKey(stv.UserID);
            lblSTVPrintedBy.Text = user.FullName ?? "-";

            txtPreprintedInvoiceNo.Text = stv.IsColumnNull("PrePrintedInvoiceNo") ? "" : stv.PrePrintedInvoiceNo.ToString();
        }
        private void gridItemsView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            DataRow dr = gridItemsView.GetFocusedDataRow();

            lblIssueType.Text = dr["OrderType"]!=DBNull.Value ? (string) dr["OrderType"] : "-";

            if ((dr["ReceivingUnitID"]) != DBNull.Value)
            {
                var ins = new Institution();
                ins.LoadByPrimaryKey(Convert.ToInt32(dr["ReceivingUnitID"]));

                lblRegion.Text = ins.RegionName ?? "-";
                lblWoreda.Text = ins.WoredaName ?? "-";
                lblZone.Text = ins.ZoneName ?? "-";

                var own = new OwnershipType();
                own.LoadByPrimaryKey(ins.Ownership);
                lblOwnership.Text = own.Name ?? "-";

                var iss = new Issue();
                iss.LoadByPrimaryKey(Convert.ToInt32(dr["STVID"]));

                if (!iss.IsColumnNull("PaymentTypeID"))
                {
                    var pType = new PaymentType();

                     pType.LoadByPrimaryKey(iss.PaymentTypeID);
                    lblPaymentType.Text = pType.Name;

                }
                lblPaymentType.Text = "-";

                if (!iss.IsColumnNull("VoidRequestDateTime"))
                    lblVoidRequestedDate.Text = iss.VoidRequestDateTime.ToShortDateString();
                else
                {
                    lblVoidRequestedDate.Text = "-";
                }
               if(!iss.IsColumnNull("VoidApprovalDateTime"))
                lblVoidConfirmedDate.Text= iss.VoidApprovalDateTime.ToShortDateString();
               else
               {
                   lblVoidConfirmedDate.Text = "-";

               }
               var user = new User();
                if (!iss.IsColumnNull("VoidRequestUserID"))
                {

                    user.LoadByPrimaryKey(iss.VoidRequestUserID);
                    lblVoidRequestedBy.Text = user.FullName;
                }
                else lblVoidRequestedBy.Text = "-";
                if (!iss.IsColumnNull("VoidApprovedByUserID"))
                {
                    user.LoadByPrimaryKey(iss.VoidApprovedByUserID);
                    lblVoidConfirmedBy.Text = user.FullName;
                }
                else lblVoidConfirmedBy.Text = "-";

                lblInstitutionType.Text = ins.InstitutionTypeName;

                if (!iss.IsColumnNull("DocumentTypeID"))
                {
                    lblDocumentType.Text = DocumentType.GetDocumentType(iss.DocumentTypeID).Name;
                }
                else
                    lblDocumentType.Text = "";

            }
            else
            {
                lblRegion.Text = lblWoreda.Text = lblZone.Text = "-";
            }

            lblPrintedDate.Text = string.IsNullOrEmpty((Convert.ToDateTime(dr["PrintedDate"].ToString())).ToShortDateString()) ? "-" : (Convert.ToDateTime(dr["PrintedDate"].ToString())).ToShortDateString();
            lblAccount.Text = string.IsNullOrEmpty(dr["AccountName"].ToString()) ? "-" : dr["AccountName"].ToString();
            lblSubAccount.Text = string.IsNullOrEmpty(dr["SubAccountName"].ToString()) ? "-" : dr["SubAccountName"].ToString();
            lblActivity.Text = string.IsNullOrEmpty(dr["ActivityName"].ToString()) ? "-" : dr["ActivityName"].ToString();
            lblPrintedBy.Text = string.IsNullOrEmpty(dr["IssuedBy"].ToString()) ? "-" : dr["IssuedBy"].ToString();

            lblIssueStatus.Text = string.IsNullOrEmpty(dr["Status"].ToString()) ? "-" : dr["Status"].ToString();
               int accountid =  Convert.ToInt32(dr["AccountID"]);
               Account account = new Account();
               account.LoadByPrimaryKey(accountid);
               Mode mode = new Mode();
               mode.LoadByPrimaryKey(account.ModeID);
               lblMode.Text = mode.TypeName;
        }
Пример #37
0
 public static void Add(User user)
 {
     _users.Add(user);
 }
        private void lkReceiptInvoice_EditValueChanged(object sender, EventArgs e)
        {
            ResetFields();

            if (lkReceiptInvoice.EditValue != null)
            {
                if ((standardRecType == StandardReceiptType.iGRVOnline || deliveryNoteType == DeliveryNoteType.Automatic) && lkReceiptInvoice.EditValue.Equals(-1))
                {
                    HandleReceiptTypeChange(true);
                    return;
                }

                if (standardRecType == StandardReceiptType.iGRV && !lkReceiptInvoice.EditValue.Equals(-1))
                {
                    //This means, the hub has chosen an invoice other than "Not Found" from the list of invoices.  Therefore, we want to change the receipt type to be iGRV-Online.
                    HandleReceiptTypeChange();
                }

                BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
                rctInvoice.LoadByPrimaryKey(Convert.ToInt32(lkReceiptInvoice.EditValue));
                var po = new PO();
                po.LoadByPrimaryKey(rctInvoice.POID);

                if (po.IsElectronic == true)
                {
                    rdIsElectronic.Checked = true;
                    lblSyncDate.Text = rctInvoice.DateOfEntry.ToShortDateString();
                    txtPassCode.Enabled = true;
                    lcPassCode.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                }
                else
                {
                    rdIsElectronic.Checked = false;
                    lblSyncDate.Text = "-";
                    txtPassCode.Enabled = false;
                    lcPassCode.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                }

                lblOrderNo.Text = po.PONumber;
                lblOrderNum.Text = po.PONumber;

                if (!rctInvoice.IsColumnNull("DocumentTypeID"))
                {
                    var doctype = new BLL.DocumentType();
                    doctype.LoadByPrimaryKey(rctInvoice.DocumentTypeID);
                    lblDeliveryNote.Text = doctype.Name;
                    lblHeaderDoc.Text = doctype.Name;
                }
                else
                {
                    lblDeliveryNote.Text = "-";
                    lblHeaderDoc.Text = "-";
                }

                var mode = new Mode();
                mode.LoadByPrimaryKey(po.ModeID);
                lblMode.Text = mode.TypeName;
                lblAccount.Text = "-";
                lblSubAccount.Text = "-";
                lblActivity.Text = "-";
                lblReferenceNo.Text = po.RefNo;

                var payment = new PaymentType();
                payment.LoadByPrimaryKey(po.PaymentTypeID);
                lblPaymentType.Text = payment.Name;
                lblHeaderPayment.Text = payment.Name;

                //if (po.IsColumnNull("NBE"))
                //{
                //    lblNebService.Text = Convert.ToString(po.NBE);
                //}
                //else
                //{
                //    lblNebService.Text = "-";
                //}

                if (po.Remaining != -1)
                    lblRemainingValue.Text = po.Remaining.ToString();
                else
                    lblRemainingValue.Text = "-";

                if (po.TotalValue != -1)
                    lblTotalValue.Text = po.Remaining.ToString();
                else
                    lblTotalValue.Text = "-";

                if (po.Insurance != -1)
                    lblChargeInsurance.Text = po.Insurance.ToString();
                else
                    lblChargeInsurance.Text = "-";

                if (po.NBE != -1)
                    lblNebService.Text = po.NBE.ToString();
                else
                    lblNebService.Text = "-";

                lblOrderDate.Text = po.PODate.ToShortDateString();
                lblReceiptDate.Text = rctInvoice.DateOfEntry.ToShortDateString();

                var user = new User();
                user.LoadByPrimaryKey(po.SavedbyUserID);
                lblOrderBy.Text =  user.FullName;

                var sup = new Supplier();

                lkAccounts.EditValue = rctInvoice.ActivityID;
                var act = new Activity();
                act.LoadByPrimaryKey(rctInvoice.ActivityID);
                _supplierID = rctInvoice.GetSupplier();
                sup.LoadByPrimaryKey(_supplierID);

                lblSupplier.Text = sup.CompanyName;
                lblOrdSup.Text = sup.CompanyName;
                lblInvoiceNo.Text = rctInvoice.STVOrInvoiceNo;

                lblInvAccount.Text = act.AccountName ?? "-";
                lblInvActivity.Text = act.Name ?? "-";
                lblAct.Text = act.FullActivityName ?? "-";
                lblInvSubAccount.Text = act.SubAccountName ?? "-";
                lblInvMode.Text = act.ModeName ?? "-";
                lblInvTotalValue.Text = rctInvoice.TotalFOBValue.ToString("N");
                lblInsurancePolicy.Text = rctInvoice.InsurancePolicyNo == " "? rctInvoice.InsurancePolicyNo : "-";

                var poType = new POType();
                poType.LoadByPrimaryKey(po.PurchaseType);
                lblOrderType.Text = poType.Name ?? "-";
                lblPOType.Text = poType.Name ?? "-";

                var poStatus = new PurchaseOrderStatus();
                poStatus.LoadByPrimaryKey(po.PurchaseOrderStatusID);
                lblOrderStatus.Text = poStatus.Name ?? "-";

                var it = new InvoiceType();
                it.LoadByPrimaryKey(rctInvoice.InvoiceTypeID);
                lblInvType.Text = it.Name;
                lblInvDate.Text = rctInvoice.DateOfEntry.ToShortDateString();

                mode.LoadByPrimaryKey(rctInvoice.ActivityID);

                lblWayBillNo.Text = rctInvoice.WayBillNo;

                txtTransitTransferVoucherNo.Text = rctInvoice.TransitTransferNo;
                txtEditTransferNo.Text = rctInvoice.TransitTransferNo;

                lblInsurancePolicyNo.Text = rctInvoice.InsurancePolicyNo;
                BLL.PO order = new PO();
                order.LoadByPrimaryKey(rctInvoice.POID);
                lblRefNo.Text = order.RefNo;
                lblPoNo.Text = order.PONumber;

                DataTable relatedReceives = rctInvoice.GetRelatedReceives();

                hasPreviousReceive = false;

                if (relatedReceives.Rows.Count > 0)
                {
                    XtraMessageBox.Show(
                        "The Invoice you have selected has previous associated receives",
                        "Invoice Detail", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        colSelectedManufactuerer.Visible = true;
                        colSelectedUnit.Visible = true;
                        colSelectionLineNo.Visible = true;
                        colSelectedReceiveQty.Visible = true;
                        colSelectedInvoiceQty.Visible = true;
                        hasPreviousReceive = true;
                        gridItemsChoice.Enabled = false;
                        colRemainingQty.VisibleIndex = 9;
                        lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                        _dtSelectedTable = relatedReceives.Clone();
                        gridSelected.DataSource = _dtSelectedTable;

                        foreach (DataRow dr in relatedReceives.Rows)
                        {
                            SelectAnItem(dr);
                        }
                }
                else
                {
                    hasPreviousReceive = false;
                    colSelectedManufactuerer.Visible = false;
                    colSelectedUnit.Visible = false;
                    colSelectionLineNo.Visible = false;
                    colSelectedReceiveQty.Visible = false;
                    colSelectedInvoiceQty.Visible = false;
                    colRemainingQty.Visible = false;
                    gridItemsChoice.Enabled = true;
                    lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                }

                if (lkAccounts.EditValue != null)
                {
                  //  lcInvoiceDetail.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                }

                if (standardRecType == StandardReceiptType.iGRVOnline || standardRecType == StandardReceiptType.GRV || deliveryNoteType == DeliveryNoteType.Automatic)
                {
                    if (!hasPreviousReceive) LoadItemsFromTransferredReceiptInvoiceDetail(rctInvoice.ID);
                    txtRefNo.Text = lkReceiptInvoice.Text;
                    colSelectedReceiveQty.Visible = true;
                    lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    lkAccounts.Enabled = false;
                }
                else
                {
                    lkAccounts.Enabled = !BLL.Settings.IsCenter;
                }

                if(!BLL.Settings.IsCenter)
                {  //Passcode Textbox
                    var dataRowView = lkReceiptInvoice.GetSelectedDataRow() as DataRowView;
                    if (dataRowView != null)
                        _isElectronic = Convert.ToBoolean(dataRowView["IsElectronic"]);

                    lcPassCode.Visibility = (!_isNonElectronicReceiveOnly) && (_isElectronic) && (standardRecType == StandardReceiptType.iGRVOnline || deliveryNoteType == DeliveryNoteType.Automatic)
                                            ? LayoutVisibility.Always
                                            : LayoutVisibility.Never;
                    txtPassCode.Text = "HHMM";
                }

            }
        }
        public Collection<Order> GetOrders()
        {
            var orders = new Collection<Order>();
            _tblRrf = (DataTable)gridItemsChoice.DataSource;
            tblRRF = (DataTable)gridItemsChoice.DataSource;

            var info = new GeneralInfo();
            info.LoadAll();

            var client1 = new ServiceRRFLookupClient();
            var req = new GetCurrentReportingPeriodRequest
            {
                Password = RRFServiceIntegration.PlitsPassword,
                UserName = RRFServiceIntegration.PlitsUserName,
                Supplychainunitid = RRFServiceIntegration.GetBranchID()
            };

            var branchReq = new GetBranchRRFormRequest
            {
                UserName = RRFServiceIntegration.PlitsUserName,
                Password = RRFServiceIntegration.PlitsPassword,
                Supplychainunitid = RRFServiceIntegration.GetBranchID()
            };

            var formReq = new GetFormsRequest
            {
                Password = RRFServiceIntegration.PlitsPassword,
                UserName = RRFServiceIntegration.PlitsUserName,
                Supplychainunitid = RRFServiceIntegration.GetBranchID()
            };

            var forms = client1.GetForms(formReq).GetFormsResult;
            var formid = forms[0].Id;

            var periods = client1.GetCurrentReportingPeriod(req).GetCurrentReportingPeriodResult;
            var period = periods[0].Id;

            branchReq.Formid = formid;
            branchReq.Reportingperiodid = period;

            var chosenCatId = 91;//RRFHelper.GetRrfCategoryId(cboStores.Text);
            var rrfs = client1.GetBranchRRForm(branchReq).GetBranchRRFormResult;
            var formCategories = rrfs.First().FormCategories;
            var chosenCategoryBody = formCategories.First(x => x.Id == chosenCatId); //Hard coding to be removed.
            var items = chosenCategoryBody.Pharmaceuticals; //Let's just store the items here (May not be required)

            var user = new User();
            user.LoadByPrimaryKey(CurrentContext.LoggedInUser.ID);
            var order = new HCMIS.Desktop.PLITSTransactionalService.Order
            {
                //Id = (int)rrf["Id"],
                RequestCompletedDate = BLL.DateTimeHelper.ServerDateTime,//Convert.ToDateTime(rrf["DateOfSubmissionEth"]),
                OrderCompletedBy = user.FullName,
                RequestVerifiedDate = BLL.DateTimeHelper.ServerDateTime,
                OrderTypeId = 1, //This needs to be changed to constant class or something. 1 - Regular, 2 - Emergency'
                SubmittedBy = user.FullName,
                SubmittedDate = BLL.DateTimeHelper.ServerDateTime,
                SupplyChainUnitId = Helpers.RRFServiceIntegration.GetBranchID(),
                OrderStatus = 1,//TODO: hardcoding
                FormId = formid,//TODO: hardcoding
                ReportingPeriodId = period  //TODO: hardcoding
            };

            // order.OrderTypeId = (int)tblrrf.Rows[i]["RRfTpyeId"];
            // Set order properties

            //order.FormId = rrfForm.Id; //Form.ID? or RRFForm.ID? - doesn't make sense
            //  order.ReportingPeriodId = periods[0].Id; //Asked again here?  Because RRFForm already contains this.

            var details = new Collection<OrderDetail>();
            int i = 0;
            var xx = tblRRF.Rows.Count;

            foreach (DataRow rrfLine in tblRRF.Rows)
            {
                var detail = new PLITSTransactionalService.OrderDetail();
                var hcmisItemID = Convert.ToInt32(rrfLine["ID"]);
                var rrFormPharmaceutical = items.FirstOrDefault(x => x.PharmaceuticalId == Convert.ToInt32(rrfLine["ID"]));
                if (rrfLine != null && rrFormPharmaceutical!=null)
                {

                    detail.BeginningBalance = Convert.ToInt32(rrfLine["BeginingBalance"]);
                    //DaysOutOfStock daysOfStockOut = new DaysOutOfStock() { NumberOfDaysOutOfStock = 1 };
                    //detail.DaysOutOfStocks.Add(daysOfStockOut);//Convert.ToInt32(rrfLine["DaysOutOfStock"]);
                    int eBalance = Convert.ToInt32(rrfLine["SOH"]);
                    detail.EndingBalance = eBalance == 0 ? 1 : eBalance;  //To make sure ending balance is not zero.
                    //detail.ItemId = Convert.ToInt32(rrfLine["ID"]); //Needs to come from the Code column of Items table.
                    detail.QuantityReceived = Convert.ToInt32(rrfLine["Received"]);
                    detail.QuantityOrdered = Convert.ToInt32(rrfLine["Quantity"]);
                    detail.LossAdjustment = Convert.ToInt32(rrfLine["LossAdj"]);

                    if (rrFormPharmaceutical != null)
                        detail.ItemId = rrFormPharmaceutical.ItemId;
                    else
                        throw new Exception("Item ID Mismatch");

                    var rdDoc = new ReceiveDoc();
                    var lossAndAdjustment = new LossAndAdjustment();
                    rdDoc.GetAllWithQuantityLeft(hcmisItemID, _storeID);
                    lossAndAdjustment.GetLossAdjustmentsForLastRRFPeriod(hcmisItemID, _storeID, periods[0].StartDate,
                                                                periods[0].EndDate);
                    int receiveDocEntries = rdDoc.RowCount;
                    int disposalEntries = lossAndAdjustment.RowCount;

                    rdDoc.Rewind();
                    for (var j = 0; j < receiveDocEntries; j++)
                    {
                        var exp = new Expiry
                                      {
                                          Amount = Convert.ToInt32(rdDoc.QuantityLeft),
                                          BatchNo = rdDoc.BatchNo,
                                          ExpiryDate = rdDoc.ExpDate
                                      };
                        detail.Expiries.Add(exp);
                        rdDoc.MoveNext();
                    }

                    lossAndAdjustment.Rewind();
                    for (var j = 0; j < disposalEntries; j++)
                    {
                        var adj = new Adjustment
                                      {Amount = Convert.ToInt32(lossAndAdjustment.Quantity), TypeId = 11, ReasonId = 39};

                        detail.Adjustments.Add(adj);
                        lossAndAdjustment.MoveNext();
                    }

                    var stockoutIndexedLists = StockoutIndexBuilder.Builder.GetStockOutHistory(hcmisItemID, _storeID);

                    for (int j = 0; j < stockoutIndexedLists.Count; j++)
                    {
                        var dos = new DaysOutOfStock
                                      {
                                          NumberOfDaysOutOfStock = stockoutIndexedLists[j].NumberOfDays,
                                          StockOutReasonId = 5
                                      };

                        detail.DaysOutOfStocks.Add(dos);
                    }

                    details.Add(detail);
                }

            }
            order.OrderDetails = details;
            orders.Add(order);

            // loop through each record and create order & order details objects
            return orders;

            //var user = new User();
            //user.LoadByPrimaryKey(NewMainWindow.LoggedInUser.ID);
            //foreach (DataRow rrf in tblRRF.Rows)
            //{
            //    var order = new HCMIS.Desktop.PLITSTransactionalService.Order
            //    {
            //        Id = (int)rrf["Id"],
            //        RequestCompletedDate = DateTime.Now,//Convert.ToDateTime(rrf["DateOfSubmissionEth"]),
            //        OrderCompletedBy = user.FullName,
            //        RequestVerifiedDate = DateTime.Now,
            //        OrderTypeId = 1, //This needs to be changed to constant class or something. 1 - Regular, 2 - Emergency'
            //        SubmittedBy = user.FullName,
            //        SubmittedDate = DateTime.Now,
            //        SupplyChainUnitId = RRFServiceIntegration.BranchID,
            //        OrderStatus = 1,
            //        FormId = formid
            //    };
            //    // order.OrderTypeId = (int)tblrrf.Rows[i]["RRfTpyeId"];
            //    // Set order properties

            //    //order.FormId = rrfForm.Id; //Form.ID? or RRFForm.ID? - doesn't make sense
            //    //  order.ReportingPeriodId = periods[0].Id; //Asked again here?  Because RRFForm already contains this.

            //    var details = new Collection<OrderDetail>();

            //    foreach (DataRow rrfLine in tblRRF.Rows)
            //    {
            //        var detail = new PLITSTransactionalService.OrderDetail();
            //        var rrFormPharmaceutical = items.FirstOrDefault(x => x.ItemId == Convert.ToInt32(rrfLine["ID"]));
            //        if (rrfLine != null && rrFormPharmaceutical != null)
            //        //detail.Adjustments[0].Amount =  (int)rrfLine["Adjustments"];
            //        {
            //            detail.BeginningBalance = Convert.ToInt32(rrfLine["BeginingBalance"]);
            //            //detail.DaysOutOfStocks = Convert.ToInt32(rrfLine["DaysOutOfStock"]);
            //            detail.EndingBalance = Convert.ToInt32(rrfLine["SOH"]);
            //            //detail.ItemId = Convert.ToInt32(rrfLine["ID"]); //Needs to come from the Code column of Items table.
            //            detail.QuantityReceived = Convert.ToInt32(rrfLine["Received"]);
            //            detail.QuantityOrdered = Convert.ToInt32(rrfLine["Quantity"]);
            //            detail.LossAdjustment = Convert.ToInt32(rrfLine["LossAdj"]);

            //            if (rrFormPharmaceutical != null)
            //                detail.PharmaceuticalId = rrFormPharmaceutical.PharmaceuticalId;
            //            //  detail.PharmaceuticalId = Convert.ToInt32(rrfLine["ItemID"]);
            //            // detail.PharmaceuticalId = pharId;

            //        }
            //        details.Add(detail);
            //    }
            //    order.OrderDetails = details;
            //    orders.Add(order);
            //}

            //// loop through each record and create order & order details objects
            //return orders;
        }
        private void btnSaveReceipt_Click(object sender, EventArgs e)
        {
            if (!IsDuplicateRowsInPutAway() || !IsPutawayValid() || !IsSumOfPalletizedQtyEqualsToReceivedQty())
            {
                return;
            }
            if (
                XtraMessageBox.Show("Are you sure you want to save this transaction?", "Confirmation",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    UpdateQuantityAndPhysicalStores();
                }
                catch (Exception ex)
                {
                    tabReceiveTabs.SelectedTabPageIndex = 1;
                    XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // start the transaction
                MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {

                    mgr.BeginTransaction();
                    // save the recieve
                    SaveReceive();
                    // save the palletization
                    // save the put away.
                    mgr.CommitTransaction();
                    PrintPutaway();

                    XtraMessageBox.Show("Your Receive has been saved!", "Confirmation", MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                    ResetFields();
                }
                catch (Exception exp)
                {
                    mgr.RollbackTransaction();
                    BLL.User user = new User();
                    //user.LoadByPrimaryKey(NewMainWindow.UserId);
                    user = CurrentContext.LoggedInUser;
                    if (user.UserType == UserType.Constants.ADMIN ||
                        user.UserType == UserType.Constants.SUPER_ADMINISTRATOR)
                    {
                        XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ErrorHandler.Handle(exp);
                    }
                    else
                    {
                        XtraMessageBox.Show(
                            "There was an Error saving this receipt. Please contact the administrator for support!",
                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ErrorHandler.Handle(exp);
                    }
                }
            }
            else
            {

            }

            _revDocRelatePalletGuid.Clear(); // clear cached pallets
        }
        /// <summary>
        /// Called when [outstanding picklist selected].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Grid.RowClickEventArgs" /> instance containing the event data.</param>
        private void OnOutstandingPicklistSelected(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            var dr = gridOutstandingPickListView.GetFocusedDataRow();
            _orderID = Convert.ToInt32(dr["ID"]);

            var order = new BLL.Order();
            order.LoadByPrimaryKey(_orderID);

            // load payment type options
            int? requestedBy = null;

            var usr = new User();

            lblIssueStatus.Text = (string)dr["OrderStatus"];
            lblIssueTypes.Text = (string) dr["Description"];

            if (!order.IsColumnNull("RequestedBy"))
            {
                var ins = new Institution();
                requestedBy = order.RequestedBy;
                lkPaymentType.Properties.DataSource = PaymentType.GetAllowedTypes(order.FromStore, requestedBy);
                ins.LoadByPrimaryKey(order.RequestedBy);

                try
                {
                    lblWoreda.Text = ins.WoredaName ?? "-";
                    lblRegion.Text = ins.RegionName ?? "-";
                    lblZone.Text = ins.ZoneName ?? "-";
                    lblInstitutionType.Text = ins.InstitutionTypeName ?? "-";

                    var ownership = new BLL.OwnershipType();
                    if (!ins.IsColumnNull("Ownership"))
                    {
                        ownership.LoadByPrimaryKey(ins.Ownership);
                        lblOwnership.Text = ownership.Name;
                    }

                }
                catch (NullReferenceException ex)
                {
                    //when transfer, institution has no woreda, zone or region, ignore the error
                }
            }
            else
                lblWoreda.Text = lblRegion.Text = lblZone.Text = lblInstitutionType.Text = lblOwnership.Text = "NA";

            //usr.LoadByPrimaryKey(NewMainWindow.UserId);
            usr = CurrentContext.LoggedInUser;
            txtIssuedBy.Text = usr.FullName ?? "-";

            PickList pl = new PickList();
            _dvOutstandingPickList = pl.GetPickListDetailsForOrder(_orderID, CurrentContext.LoggedInUserName);
            gridOutstandingPicklistDetail.DataSource = _dvOutstandingPickList;

            if (order.FromStore != Mode.Constants.HEALTH_PROGRAM)
            {
                colSKUPicked.Visible = false;
            }
            else
            {
                colSKUPicked.Visible = true;
            }

            txtConfirmFromStore.Text = order.GetFromStore();
            txtConfirmRequestedBy.Text = order.GetRequestedBy();

            int length = order.GetRequestedBy().Length;

            string s = "";

            HeaderSection.Text = order.GetRequestedBy() + s.PadRight(150-length)+"Order Number: " + order.RefNo;

            txtConfirmOrderNumber.Text = order.RefNo;
            //txtConfirmApprovedBy.Text = order.GetApprovedBy() ?? "-";
            lblApprovedBy.Text = order.GetApprovedBy() ?? "-";

            lkPaymentType.EditValue = order.PaymentTypeID;
            // Temporarily copy the STV
            txtIssueRefNo.Text = order.RefNo; //"";
            lblRefNo.Text = order.RefNo ?? "-";

            var paymentType = new BLL.PaymentType();
            paymentType.LoadByPrimaryKey(order.PaymentTypeID);
            lblPaymentType.Text = paymentType.Name ?? "-";

            lblMode.Text = order.GetFromStore() ?? "-";
            lblissuedDate.Text = order.Date.ToShortDateString();
            lblIssuedBy.Text = order.GetFilledBy();
            lblPicklistPrintedDate.Text = pl.PickedDate.ToShortDateString()!="" ? pl.PickedDate.ToShortDateString() : "-";

            var us = new User();
            pl.LoadByOrderID(_orderID);
            if (!pl.IsColumnNull("PickedBy"))
            {
                us.LoadByPrimaryKey(pl.PickedBy);
                lblPicklistConfirmedBy.Text = us.FullName;
            }
            else lblPicklistConfirmedBy.Text = "-";
        }
        private void gridDetailReport_KeyDown(object sender, KeyEventArgs e)
        {
            // this has to be removed after development
            BLL.User user = new User();
            //user.LoadByPrimaryKey(NewMainWindow.UserId);
            user = CurrentContext.LoggedInUser;

            if (e.Control && e.Alt && user.UserType == UserType.Constants.SUPER_ADMINISTRATOR)
            {
                DataRow dr = (gridDetailReport.MainView as GridView).GetFocusedDataRow();
                //gridReadinessView.GetFocusedDataRow();
                if (dr != null)
                {
                    int itemId = Convert.ToInt32(dr["ID"]);
                    Diagnostics diagnostics = new Diagnostics(itemId);
                    diagnostics.WindowState = FormWindowState.Maximized;
                    diagnostics.Show();
                }
            }
        }
 /// <summary>
 /// Update the form based on the selected user
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void lstUsers_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstUsers.SelectedItems.Count > 0)
     {
         int selected = Convert.ToInt32(lstUsers.SelectedItems[0].Tag);
         User us = new User();
         us.LoadByPrimaryKey(selected);
         txtFullName.Text = us.FullName;
         txtAddress.Text = us.Address;
         txtMobile.Text = us.Mobile;
         ckActive.Checked = us.Active;
         cboUserType.SelectedValue = us.UserType.ToString();
         _userId = us.ID;
         groupBox3.Enabled = false;
     }
 }
        /// <summary>
        /// Load all the stores and put them in the combo box
        /// Set the logged in user name in the issued by text box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void IssuingForm_Load(object sender, EventArgs e)
        {
            var unitcolumn = ((GridView)gridItemsChoice.MainView).Columns[4];
            var unitid = ((GridView)issueGrid.MainView).Columns[14];
            var unitcolumn1 = ((GridView)issueGrid.MainView).Columns[2];
            var duamc = ((GridView)issueGrid.MainView).Columns[8];
            var mrdusoh = ((GridView)issueGrid.MainView).Columns[6];
            var recommendedqty = ((GridView)issueGrid.MainView).Columns[9];
            var requestedqty = ((GridView)issueGrid.MainView).Columns[12];
            var qtyperpack = ((GridView)issueGrid.MainView).Columns[11];
            var unitcolumn3 = ((GridView)gridItemsChoice.MainView).Columns[14];
            switch (VisibilitySetting.HandleUnits)
            {
                case 3:
                    unitcolumn.Visible = false;
                    unitcolumn1.Visible = false;
                    unitid.Visible = true;
                    qtyperpack.Visible = true;
                    mrdusoh.Visible = true;
                    duamc.Visible = true;
                    recommendedqty.Visible = true;
                    duamc.Visible = true;
                    requestedqty.Visible = false;
                    unitcolumn3.Visible = true;
                    break;
                case 2:
                    unitcolumn.Visible = false;
                    unitcolumn1.Visible = false;
                    unitid.Visible = true;
                    qtyperpack.Visible = true;
                    mrdusoh.Visible = false;
                    recommendedqty.Visible = false;
                    duamc.Visible = false;
                    requestedqty.Visible = false;
                    unitcolumn3.Visible = true;
                    break;
                default:
                    unitcolumn.Visible = true;
                    unitcolumn1.Visible = true;
                    unitid.Visible = false;
                    qtyperpack.Visible = true;
                    duamc.Visible = true;
                    unitcolumn3.Visible = false;
                    break;
            }

            PopulateCatTree(_selectedType);
            var stor = new Stores();
            stor.GetActiveStores();
            storebindingSource.DataSource = stor.DefaultView;
            cboStores.Properties.DataSource = storebindingSource.DataSource;
            cboStores.ItemIndex = 0;
            cboStores.Properties.DisplayMember = "StoreName";
            cboStores.Properties.ValueMember = "ID";
            cboStoreConf.Properties.DataSource = stor.DefaultView;
            lkCategories.Properties.DataSource = BLL.Type.GetAllTypes();
            lkCategories.ItemIndex = 0;

            var unit = new ItemUnit();
            var xx = unit.GetAllUnits();
            UnitsbindingSource.DataSource = xx.DefaultView;

            var userID = MainWindow.LoggedinId;
            var us = new User();
            us.LoadByPrimaryKey(userID);
            txtIssuedBy.Text = us.FullName;

            if (!chkExcludeStockedOut.Checked)
                gridItemChoiceView.ActiveFilterString = String.Format("TypeID={0}", Convert.ToInt32(lkCategories.EditValue));
        }
        private void gridReceiveView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // Bind the detail grid
            PalletLocation pl = new PalletLocation();
            try
            {
                ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
                BLL.Receipt receiptDoc = new BLL.Receipt();
                var rd = new ReceiveDoc();
                rd.LoadByReceiptID(ReceiptID);

                var ps = new PhysicalStore();
                ps.LoadByPrimaryKey(rd.PhysicalStoreID);

                var w = new BLL.Warehouse();
                w.LoadByPrimaryKey(ps.PhysicalStoreTypeID);
                lblWarehouse.Text = w.Name ?? "-";

                var c = new Cluster();
                c.LoadByPrimaryKey(w.ClusterID);
                lblCluster.Text = c.Name ?? "-";

                receiptDoc.LoadByPrimaryKey(ReceiptID);
                DataTable GRNFDetail =  receiptDoc.GetDetailsForGRNF();
                gridDetails.DataSource = GRNFDetail;
                gridShortage.DataSource = receiptDoc.GetDiscrepancyForGRNF();
                int status = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["Status"]);

                var SelectGRV = gridReceiveView.GetFocusedDataRow();

                lblMode.Text = (string)SelectGRV["ModeName"];
                lblAccount.Text = (string)SelectGRV["AccountName"];
                lblSubAccount.Text = (string)SelectGRV["SubAccountName"];
                lblActivity.Text = (string)SelectGRV["ActivityName"];
                lblSupplier.Text = (string)SelectGRV["SupplierName"];
                lblPONumber.Text = (string)SelectGRV["PONo"];

                lblType.Text = (string)SelectGRV["ReceiptType"];
                lblStatus.Text = (string)SelectGRV["CurrentStatus"];

                var lgs = new LogReceiptStatus();
                lgs.LoadByReceiptID(ReceiptID);

                lblCalculatedDate.Text = lgs.StatusChangedDate.ToShortDateString();

                var user = new User();
                if (SelectGRV["calculatedBy"] != DBNull.Value)
                {
                    user.LoadByPrimaryKey(Convert.ToInt32(SelectGRV["calculatedBy"]));
                    lblCalculatedBy.Text = user.FullName;
                }

                else
                {
                    lblCalculatedBy.Text = "-";
                }

                lblCostConfirmedBy.Text = SelectGRV["confirmedBy"] != DBNull.Value ? SelectGRV["confirmedBy"].ToString() : "-";

                //lblGRVNumber.Text = reference;
                //lblRecivedDate.Text = ((DateTime)SelectGRV["Date"]).ToShortDateString();
                lblCostConfirmedDate.Text = SelectGRV["confirmedDate"] != DBNull.Value ? Convert.ToDateTime(SelectGRV["confirmedDate"]).ToShortDateString() : "-";

                string s = "";

                int length = ((string)SelectGRV["STVOrInvoiceNo"]).Length;
                string grv = (Convert.ToInt32(SelectGRV["IDPrinted"])).ToString();
                HeaderGroup.Text = "Invoice No: " + (string)SelectGRV["STVOrInvoiceNo"] + s.PadRight(240 - length) + "GRV No: " + grv ;

                //ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
                //ds = new DataSet();
                //DataTable dvMaster = pl.GetDetailsOfByReceiptID(ReceiptID);
                //dvMaster.TableName = "Master";
                //ds.Tables.Add(dvMaster);
                //gridDetails.DataSource = ds.Tables[dvMaster.TableName];

                //var receipt = new BLL.Receipt();
                //receipt.LoadByPrimaryKey(ReceiptID);
                //int receiptTypeID = receipt.ReceiptTypeID;

                if (currentMode == Modes.GRVPrinting)
                {
                    if (status != ReceiptConfirmationStatus.Constants.PRICE_CONFIRMED)
                    {
                        gridDetails.Enabled = false;

                        btnConfirm.Enabled = false;
                        btnPrint.Enabled = false;
                        btnReturn.Enabled = false;
                    }
                    else
                    {
                        gridDetails.Enabled = true;
                        btnConfirm.Enabled = true;
                        btnPrint.Enabled = true;
                        btnReturn.Enabled = true;
                    }
                }
            }

            catch
            {
                gridDetails.DataSource = null;
                gridShortage.DataSource = null;
            }
        }
        private void PopulateUser()
        {
            User us = new User();
            gridUsers.DataSource = us.GetUsers();

            UserType uType = new UserType();
            uType.LoadAllButSysAdmin();
            cboUserType.DataSource = uType.DefaultView;
        }