Ejemplo n.º 1
0
        private void BindddNazar()
        {
            DataSet ds = CatalogClass.GetListTypeID("11");

            ddnazar.DataSource     = ds;
            ddnazar.DataTextField  = "CatalogName";
            ddnazar.DataValueField = "CatalogValue";
            ddnazar.DataBind();


            ddRequestStatus.DataSource     = ds;
            ddRequestStatus.DataTextField  = "CatalogName";
            ddRequestStatus.DataValueField = "CatalogValue";
            ddRequestStatus.DataBind();
            ddRequestStatus.Items.Insert(0, new ListItem("همه موارد", "-1"));
            ddRequestStatus.Items.Insert(1, new ListItem("پرداخت شده", "-2"));

            ClCompany cl = new ClCompany();

            ddcompany.DataSource     = CompanyClass.GetList(cl);
            ddcompany.DataTextField  = "CompanyName";
            ddcompany.DataValueField = "CompanyID";
            ddcompany.DataBind();
            ddcompany.Items.Insert(0, new ListItem("بدون انتخاب", "0"));


            ds.Dispose();
        }
Ejemplo n.º 2
0
        public void GetCompany()
        {
            CompanyClass com = new CompanyClass();
              company comp =com.getCompanyByName(Request.Form["name"]);
              if (comp != null)
              {
              Response.Write("success," + comp.name + "," );
              foreach (product p in comp.products)
              {

                  Response.Write(p.name+"&&"+p.price+" ج &&"+p.enterDate.ToString("yyyy-MM-dd")+"&&");

                  int currentCost = 0;
                  foreach (productPay pp in p.productPays)
                  {
                      currentCost += pp.cost;
                      Response.Write(pp.cost + " ج %%" + pp.payDate.ToString("yyyy-MM-dd")+"%%"+pp.id+"##");
                  }

                  Response.Write("&&" + currentCost + " ج &&" + p.notes + "&&"+p.id+ "^^");
              }
              }
              else
              {
              Response.Write("fail");
              }
        }
Ejemplo n.º 3
0
        protected void BtnInsert_Click(object sender, EventArgs e)
        {
            ClCompany cl = new ClCompany();

            cl = Data;
            int i = 0;

            if (LblParamCompanyID.Text == "0")
            {
                i = CompanyClass.insert(cl);
            }
            else
            {
                i = CompanyClass.Update(cl);
            }



            if (i.ToString() == "0")
            {
                Utility.ShowMsg(Page, ProPertyData.MsgType.General_Fault, "ثبت با خطا مواجه شد");
            }
            else
            {
                // Utility.ShowMsg(Page, ProPertyData.MsgType.General_Success, "ثبت با موفقیت انجام شد.");
                //Session["CompanyID"] = LblParamCompanyID.Text;
                BindGrid();
                LightBox.Value = "0";
            }
            LblParamCompanyID.Text = "0";
        }
Ejemplo n.º 4
0
        public int  CompnaytypeID()
        {
            string    ctype = "0";
            ClCompany cl    = new ClCompany();

            cl.PersonalID = PersonID;
            DataSet ds = CompanyClass.GetListPersonl(cl);

            if (ds.Tables[0].Rows.Count > 0)
            {
                ctype = ds.Tables[0].Rows[0]["CompanyTypeID"].ToString();
                if (ctype == "2")
                {
                    sa1.Visible = true;
                    sa2.Visible = true;
                }
                else
                {
                    sa1.Visible = false;
                    sa2.Visible = false;
                }
            }
            else
            {
                sa1.Visible = false;
                sa2.Visible = false;
                ctype       = "-1";
            }
            return(Convert.ToInt32(ctype));
        }
Ejemplo n.º 5
0
        public List <CompanyClass> GetDataSource()
        {
            SqlConnection con     = new SqlConnection(Constring);
            string        query   = @"SELECT * FROM CompanyTable";
            SqlCommand    command = new SqlCommand(query, con);

            con.Open();

            SqlDataAdapter da = new SqlDataAdapter(command);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            con.Close();


            List <CompanyClass> company = new List <CompanyClass>();

            foreach (DataRow a in dt.Rows)
            {
                CompanyClass companyc = new CompanyClass();
                // dipstudent.Id = Convert.ToInt32(a["Id"]);
                companyc.Name = a["Name"].ToString();
                //dipstudent.Code = a["Code"].ToString();
                //dipstudent.Address = a["Address"].ToString();
                company.Add(companyc);
            }
            return(company);
        }
Ejemplo n.º 6
0
    public List <CompanyClass> CheckCompanyID(string companyID)
    {
        List <CompanyClass> company = new List <CompanyClass>();
        CompanyClass        objemp  = new CompanyClass();

        company = objemp.CheckCompanyID(companyID);
        return(company);
    }
Ejemplo n.º 7
0
        public void BindDD()
        {
            ClCompany cl = new ClCompany();
            DataSet   ds = CompanyClass.GetList(new ClCompany());

            ddCompany.DataSource     = ds;
            ddCompany.DataTextField  = "CompanyName";
            ddCompany.DataValueField = "CompanyID";
            ddCompany.DataBind();
        }
Ejemplo n.º 8
0
        private void twUsers_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            CompanyClass uc = e.Node.Tag as CompanyClass;

            txtTrivetId.Text     = uc.CompanyID.ToString();
            txtTrivetName.Text   = uc.CompanyName;
            textTrivetCount.Text = uc.CompanyCount.ToString();

            //   twUserAssociated.Nodes.Clear();
        }
Ejemplo n.º 9
0
        private void twWishItems_AfterSelect(object sender, TreeViewEventArgs e)
        {
            twTrivet.Nodes.Clear();
            List <CompanyClass> _users = CompanyClass.GetAllCompany();

            foreach (CompanyClass user in _users)
            {
                TreeNode tn = new TreeNode(user.CompanyName);
                tn.Tag = user;
                twTrivet.Nodes.Add(tn);
            }
        }
Ejemplo n.º 10
0
        private void LoadSomeData(String s)
        {
            twDataItems.Nodes.Clear();
            List <DataClass> items = DataClass.GetSomeData(CompanyClass.GetAllCompanyWithName(s));

            foreach (DataClass dc in items)
            {
                TreeNode tn = new TreeNode(CompanyClass.GetCompanyNameByCompanyIDAsString(DataClass.GetCompanyIDFromDataIDAsString(dc.DataID)) + dc.DataWeight.ToString() + "g " + dc.DataTime);
                tn.Tag = dc;
                twDataItems.Nodes.Add(tn);
            }
        }
Ejemplo n.º 11
0
        private void LoadAllCompanies()
        {
            twCompany.Nodes.Clear();
            List <CompanyClass> _company = CompanyClass.GetAllCompany();

            foreach (CompanyClass company in _company)
            {
                TreeNode tn = new TreeNode(company.CompanyName + "      (" + company.CompanyCount + ") ");
                tn.Tag = company;
                twCompany.Nodes.Add(tn);
            }
        }
Ejemplo n.º 12
0
 public void deleteDof3a()
 {
     int Id = int.Parse(Request.Form["id"]);
     CompanyClass com = new CompanyClass();
     if (com.deleteDof3a(Id))
     {
         Response.Write("success");
     }
     else
     {
         Response.Write("fail");
     }
 }
Ejemplo n.º 13
0
 public ActionResult UserEdit()
 {
     try
     {
         Company      company = db.Company.Find(GlobalClass.Company.CompanyKey);
         CompanyClass model   = val.FillCompanyInfo(company);
         return(View(model));
     }
     catch (Exception e)
     {
         return(View("Error", new HandleErrorInfo(e, "Index", "UserHome")));
     }
 }
Ejemplo n.º 14
0
 public ActionResult UserEdit(CompanyClass company, HttpPostedFileBase file)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Company obj = db.Company.Find(company.CompanyKey);
             if (file != null)
             {
                 byte[] data = null;
                 using (Stream inputStream = file.InputStream)
                 {
                     MemoryStream memoryStream = inputStream as MemoryStream;
                     if (memoryStream == null)
                     {
                         memoryStream = new MemoryStream();
                         inputStream.CopyTo(memoryStream);
                     }
                     data = memoryStream.ToArray();
                 }
                 obj.Logo     = data;
                 obj.LogoType = file.ContentType;
             }
             company               = val.ValidateCompanyClass(company);
             obj.CompanyID         = company.CompanyID;
             obj.CompanyName       = company.CompanyName;
             obj.ZIPKey            = company.ZIPKey;
             obj.StateCode         = company.StateCode;
             obj.CityKey           = company.CityKey;
             obj.CompanyAddress    = company.CompanyAddress;
             obj.CompanyPhone      = company.CompanyPhone;
             obj.CompanyMobile     = company.CompanyMobile;
             obj.CompanyEmail      = company.CompanyEmail;
             obj.CompanyWebsite    = company.CompanyWebsite;
             obj.CompanyFax        = company.CompanyFax;
             obj.ContactPersonName = company.ContactPersonName;
             obj.ContactPersonNo   = company.ContactPersonNo;
             obj.Title             = company.Title;
             obj.ContactEmail      = company.ContactEmail;
             db.SaveChanges();
             return(RedirectToAction("UserDetails"));
         }
         return(View(company));
     }
     catch (Exception e)
     {
         return(View("Error", new HandleErrorInfo(e, "Index", "UserHome")));
     }
 }
Ejemplo n.º 15
0
        public void BindDD()
        {
            ClCompany cl = new ClCompany();

            DDCompanyID.DataSource     = CompanyClass.GetList(cl);
            DDCompanyID.DataTextField  = "CompanyName";
            DDCompanyID.DataValueField = "CompanyID";
            DDCompanyID.DataBind();
            DDCompanyID.Items.Insert(0, new ListItem("", "0"));

            //DDDiscountTypeID.DataSource = CatalogClass.GetListDiscountType();
            //DDDiscountTypeID.DataTextField = "CatalogName";
            //DDDiscountTypeID.DataValueField = "caid";
            //DDDiscountTypeID.DataBind();
        }
Ejemplo n.º 16
0
        private string GetCompanyID(int PersonalId)
        {
            ClCompany clCompany = new ClCompany();

            clCompany.PersonalID = PersonalId;
            DataSet ds = CompanyClass.GetListPersonl(clCompany);
            DataRow dr;

            if (ds.Tables[0].Rows.Count > 0)
            {
                dr = ds.Tables[0].Rows[0];
                lblCompanyID.Text = dr["CompanyID"].ToString();
            }
            ds.Dispose();
            return(lblCompanyID.Text);
        }
Ejemplo n.º 17
0
        public bool DuplicateCheck(CompanyClass _companyClass)
        {
            SqlConnection con   = new SqlConnection(Constring);
            string        quary = @"Select * from CompanyTable Where Name='" + _companyClass.Name + "' ";
            SqlCommand    cmd   = new SqlCommand(quary, con);

            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 18
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Request.QueryString["cname"] == null)
         {
             ClCompany cl = new ClCompany();
             cl.companyID = Convert.ToInt32(Request.QueryString["cid"]);
             DataSet ds = CompanyClass.GetList(cl);
             DataRow dr = ds.Tables[0].Rows[0];
             lblCompanyName.Text = dr[""].ToString();
         }
         lblCompanyName.Text = Request.QueryString["cname"].ToString();
     }
     catch { }
 }
Ejemplo n.º 19
0
        private void BindGrid()
        {
            ClCompany cl = new ClCompany();

            cl.YearIDfilter = Convert.ToInt32(ddDefauleYear.SelectedValue);
            DataSet  ds = CompanyClass.GetListCompanyRequest(cl);
            DataView dv = new DataView(ds.Tables[0]);

            if (ViewState["PersonalID"] == null)
            {
                ViewState["PersonalID"] = "PersonalID Desc";
            }
            dv.Sort          = Securenamespace.SecureData.CheckSecurity(ViewState["PersonalID"].ToString()).ToString();
            grid1.DataSource = dv;
            grid1.DataBind();
        }
Ejemplo n.º 20
0
        public void BindGrid()
        {
            ClCompany cl = new ClCompany();

            cl = Data;

            DataSet  ds = CompanyClass.GetList(cl);
            DataView dv = new DataView(ds.Tables[0]);

            if (ViewState["CompanyID"] == null)
            {
                ViewState["CompanyID"] = "CompanyID Desc";
            }
            dv.Sort = ViewState["CompanyID"].ToString();
            GridView1.DataSource = dv;
            GridView1.DataBind();
        }
Ejemplo n.º 21
0
        public bool Save(CompanyClass _companyClass)
        {
            SqlConnection con   = new SqlConnection(Constring);
            string        query = @"Insert into  CompanyTable (Name) Values('" + _companyClass.Name + "')";
            SqlCommand    cmd   = new SqlCommand(query, con);

            con.Open();
            int rowAffected = cmd.ExecuteNonQuery();

            con.Close();
            if (rowAffected > 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 22
0
        //Save Company - Also updates the TreeNode and Resets the textboxes so you can't overwrite the newly made entity. Pop-up box with if it saved or not
        private void btnSaveCompany_Click(object sender, EventArgs e)
        {
            CompanyClass cc = new CompanyClass();

            cc.CompanyID    = System.Convert.ToInt32(txtCompanyId.Text);
            cc.CompanyName  = txtCompanyName.Text;
            cc.CompanyCount = System.Convert.ToInt32(txtCompanySize.Text);
            if (cc.SaveMe("") != true)
            {
                MessageBox.Show("Could not save");
            }
            else
            {
                MessageBox.Show("Company Saved");
                LoadAllCompanies();
                ResetCompany();
            }
        }
Ejemplo n.º 23
0
        //遍历子公司
        private void RecursivelyCompanyClass(Guid companyClassId, RadTreeNode node)
        {
            var companyClass = new CompanyClass(GlobalConfig.DB.FromType.Read);
            IList <CompanyClassInfo> childCompanyClassList = companyClass.GetChildCompanyClassList(companyClassId);

            foreach (CompanyClassInfo companyClassInfo in childCompanyClassList)
            {
                if (string.IsNullOrWhiteSpace(companyClassInfo.CompanyClassName))
                {
                    continue;
                }
                RadTreeNode childNode = CreateNode(companyClassInfo.CompanyClassName, "BusinessRelatedUnits", false, companyClassInfo.CompanyClassId.ToString());
                childNode.PostBack = true;
                node.Nodes.Add(childNode);
                RecursivelyCompanyClass(companyClassInfo.CompanyClassId, childNode);
                RepetitionCompanyCussent(companyClassInfo.CompanyClassId, childNode);
            }
        }
    /// <summary>
    /// Clear the invite and send a whisper letting them know that
    /// this has occured.
    /// </summary>
    /// <param name="companyName"></param>
    /// <returns></returns>
    IEnumerator ClearInvite(string companyName)
    {
        Debug.Log("Clearing invite.");

        yield return(new WaitForSeconds(300));

        company = companies[companyName];
        string invitedUsername = company.GetFirstInvite();

        company.RemoveFirstInvite();

        string founderUsername = company.GetOwner;

        // TODO - Currently whispers are broken
        client.SendWhisper(founderUsername, "Your invite to " + invitedUsername + " has run out.");

        Debug.Log("Invite ran out.");
    }
Ejemplo n.º 25
0
        public bool Save(CompanyClass _companyClass)
        {
            bool dupCheck = _companyRepository.DuplicateCheck(_companyClass);

            if (dupCheck)
            {
                MessageBox.Show("Name is Exist");
            }
            else
            {
                bool isSave = _companyRepository.Save(_companyClass);
                if (isSave)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 26
0
        public void DeleteItem(object sender, System.EventArgs e)
        {
            String cid = ((HtmlAnchor)sender).HRef.ToString();
            //ClCompany cl = new ClCompany();
            //cl.CompanyID = Convert.ToInt32(cid);

            int i = CompanyClass.Delete(cid);

            if (i == 0)
            {
                Utility.ShowMsg(Page, ProPertyData.MsgType.warning, "خطا در حذف");
                //ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('خطا در حذف');", true);
            }
            else
            {
                BindGrid();
            }

            LightBox.Value = "0";
        }
Ejemplo n.º 27
0
        public void AddDof3a()
        {
            int productId = int.Parse(Request.Form["id"]);
            int cost = int.Parse(Request.Form["cost"]);

            DateTime date;
            CultureInfo enUS = new CultureInfo("en-US");
            DateTime.TryParseExact(Request.Form["date"], "yyyy-MM-dd", enUS,
                        DateTimeStyles.None, out date);
            CompanyClass com = new CompanyClass();
            int productPayId = 0;
            if (com.AddDof3a(productId, cost, date , out productPayId))
            {
                Response.Write("success," + productPayId);
            }
            else
            {
                Response.Write("fail");
            }
        }
 public DiConnectionCompany(string server, int dbServerType, string userName, string password, string companyDb)
 {
     Company = new CompanyClass
     {
         Server       = server,
         DbServerType = (BoDataServerTypes)dbServerType,
         UserName     = userName,
         Password     = password,
         CompanyDB    = companyDb,
         language     = BoSuppLangs.ln_English
     };
     Company.Connect();
     if (!Company.Connected)
     {
         throw new Exception($"Cannot Connect To the Server : {Company.GetLastErrorDescription()} : " +
                             $"Server : {Company.Server}, " +
                             $"DbServerType : {Company.DbServerType}," +
                             $"UserName : {Company.UserName}," +
                             $"CompanyDB : {Company.CompanyDB}");
     }
 }
        private string CreateCustomerID(CompanyClass classID)
        {
            string id = null;

            if (classID == CompanyClass.Customer)
            {
                id = ProviderFactory.Create <IAutoNumberCreater>(RepoUri).CreateNumber(UserSettings.Current.CustomerPrefix, UserSettings.Current.CustomerSerialCount, "customer");
            }
            else if (classID == CompanyClass.Supplier)
            {
                id = ProviderFactory.Create <IAutoNumberCreater>(RepoUri).CreateNumber(UserSettings.Current.SupplierPrefix, UserSettings.Current.SupplierSerialCount, "supplier");
            }
            else if (classID == CompanyClass.Proxy)
            {
                id = ProviderFactory.Create <IAutoNumberCreater>(RepoUri).CreateNumber("P", 3, "ProxyCompany");
            }
            else
            {
                id = ProviderFactory.Create <IAutoNumberCreater>(RepoUri).CreateNumber("RC", 3, "relatedCompany");
            }
            return(id);
        }
Ejemplo n.º 30
0
        /// <summary>获取往来单位分类
        /// </summary>
        /// <param name="companyClassId"></param>
        /// <param name="depth"></param>
        /// <returns></returns>
        public static IList <CompanyClassInfo> RecursionCompanyClass(Guid companyClassId, int depth)
        {
            depth++;
            var companyClass = new CompanyClass(GlobalConfig.DB.FromType.Read);
            IList <CompanyClassInfo> companyClassTree = new List <CompanyClassInfo>();

            IList <CompanyClassInfo> companyClassList = companyClass.GetChildCompanyClassList(companyClassId);
            string tag = depth == 1 ? "+" : "|" + new String('-', depth * 2);

            foreach (CompanyClassInfo companyClassInfo in companyClassList)
            {
                companyClassInfo.CompanyClassName = tag + companyClassInfo.CompanyClassName;
                companyClassTree.Add(companyClassInfo);
                foreach (
                    CompanyClassInfo childCompanyClassInfo in
                    RecursionCompanyClass(companyClassInfo.CompanyClassId, depth))
                {
                    companyClassTree.Add(childCompanyClassInfo);
                }
            }
            return(companyClassTree);
        }
Ejemplo n.º 31
0
        private void CompanySelectForm_Load(object sender, EventArgs e)
        {
            CompanyClass cn = new CompanyClass();

            DataTable dt = cn.getAllCompany();

            foreach (DataRow d in dt.Rows)
            {
                Button bt = new Button();
                bt.Tag       = d["com_id"];
                bt.BackColor = Color.DodgerBlue; //Color.FromArgb(0, 0, 180, 255);
                bt.ForeColor = Color.White;
                bt.Font      = new Font("Tahoma", 10, FontStyle.Bold);
                bt.Cursor    = Cursors.Hand;
                bt.FlatStyle = FlatStyle.Flat;
                bt.Width     = 250;
                bt.Padding   = new Padding(5, 5, 5, 5);
                bt.AutoSize  = true;
                bt.Text      = d["com_name"].ToString();
                bt.Click    += Bt_Click;
                flowLayoutPanel1.Controls.Add(bt);
            }
        }
Ejemplo n.º 32
0
        public int InsertCompany(CompanyClass comp)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlCommand cmdQual = new SqlCommand("INSERT INTO Company(CompanyID, CompanyName, RegistrationNum, FspNum, Title, FirstName, Surname, Initials, Designation, PhoneNo, FaxNo, CellNo, Email, Address, Region, Suburb, Town, PostalCode) VALUES(@CompanyID, @CompanyName, @RegistrationNum, @FspNum, @Title, @FirstName, @Surname, @Initials, @Designation, @PhoneNo, @FaxNo, @CellNo, @Email, @Address, @Region, @Suburb, @Town, @PostalCode)", conn);

                cmdQual.Parameters.Add(new SqlParameter("@CompanyID", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@CompanyID"].Value = comp.CompanyID;

                cmdQual.Parameters.Add(new SqlParameter("@CompanyName", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@CompanyName"].Value = comp.CompanyName;

                cmdQual.Parameters.Add(new SqlParameter("@RegistrationNum", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@RegistrationNum"].Value = comp.RegistrationNum;

                cmdQual.Parameters.Add(new SqlParameter("@FspNum", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@FspNum"].Value = comp.FspNum;

                cmdQual.Parameters.Add(new SqlParameter("@Title", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Title"].Value = comp.Title;

                cmdQual.Parameters.Add(new SqlParameter("@FirstName", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@FirstName"].Value = comp.FirstName;

                cmdQual.Parameters.Add(new SqlParameter("@Surname", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Surname"].Value = comp.Surname;

                cmdQual.Parameters.Add(new SqlParameter("@Initials", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Initials"].Value = comp.Initials;

                cmdQual.Parameters.Add(new SqlParameter("@Designation", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Designation"].Value = comp.Designation;

                cmdQual.Parameters.Add(new SqlParameter("@PhoneNo", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@PhoneNo"].Value = comp.PhoneNo;

                cmdQual.Parameters.Add(new SqlParameter("@FaxNo", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@FaxNo"].Value = comp.FaxNo;

                cmdQual.Parameters.Add(new SqlParameter("@CellNo", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@CellNo"].Value = comp.CellNo;

                cmdQual.Parameters.Add(new SqlParameter("@Email", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Email"].Value = comp.Email;

                cmdQual.Parameters.Add(new SqlParameter("@Address", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Address"].Value = comp.Address;

                cmdQual.Parameters.Add(new SqlParameter("@Region", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Region"].Value = comp.Region;

                cmdQual.Parameters.Add(new SqlParameter("@Suburb", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Suburb"].Value = comp.Suburb;

                cmdQual.Parameters.Add(new SqlParameter("@Town", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@Town"].Value = comp.Town;

                cmdQual.Parameters.Add(new SqlParameter("@PostalCode", System.Data.SqlDbType.NVarChar));
                cmdQual.Parameters["@PostalCode"].Value = comp.PostalCode;
                try
                {
                    conn.Open();
                    return(cmdQual.ExecuteNonQuery());
                }

                catch (SqlException ex)
                {
                    throw new ApplicationException("Error adding Company\n\n" + ex.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 33
0
        public static bool ProcessItem(string fileContent)
        {
            item item = new item();

            DALPortalDataContext dc = new DALPortalDataContext();
            Boolean update;
            String  companyCode = String.Empty;

            //outCompanyCode = String.Empty;

            try
            {
                XDocument xmldoc            = XDocument.Parse(fileContent);
                XElement  docTypeElement    = xmldoc.Element("MATMAS05");
                XElement  iDocElement       = docTypeElement.Element("IDOC");
                var       itemHeaderElement = iDocElement.Element("E1MARAM");

                // ItemCode, remove leading zero's from ItemCode
                String itemCode    = RemoveLeadingZeros(itemHeaderElement.Element("MATNR").Value).ToString();
                String sectionCode = itemHeaderElement.Element("E1MVKEM").Element("VKORG").Value;

                companyCode = CompanyClass.GetCompanyBasedOnSection(sectionCode, dc);

                // Check if item Already exists
                item = ItemClass.GetItem(itemCode, companyCode, dc);
                if (item == null)
                {
                    item   = new item();
                    update = false;
                }
                else
                {
                    update = true;
                }

                if (!update)
                {
                    item.companyCode = companyCode;
                }

                // Mapp customer header data
                item.itemCode = itemCode;

                // English description
                XElement ItemDescElement = itemHeaderElement.Elements("E1MAKTM").ToList().Where(c => c.Element("MSGFN").Value.Equals("005") && c.Element("SPRAS_ISO").Value.Equals("EN")).FirstOrDefault();
                if (ItemDescElement != null)
                {
                    XElement ItemDescElement2 = ItemDescElement.Element("MAKTX");
                    if (ItemDescElement2 != null)
                    {
                        item.description = ItemDescElement2.Value;
                    }
                }

                // Certificate Type.
                // 00 = Cert. Niet van toepassing
                if (itemHeaderElement.Elements().Any(c => c.Name.ToString().Equals("GTIN_VARIANT")))
                {
                    item.CertificateType = itemHeaderElement.Element("GTIN_VARIANT").Value;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(String.Format("Error converting item {0} for company {1} from SAP ECC6 XML format. Error: {2}", item.itemCode, companyCode, ex.Message), "ProcessItem");
                return(false);
            }

            if (update)
            {
                try
                {
                    dc.SubmitChanges();
                    Trace.WriteLine(String.Format("Updating Item {0} for company {1} Successfull.", item.itemCode, companyCode), "ProcessItem");
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(String.Format("Error Updating Item {0} for company {1}. Error: {2}", item.itemCode, companyCode, ex.Message), "ProcessItem");
                    return(false);
                }
            }
            else
            {
                try
                {
                    dc.items.InsertOnSubmit(item);
                    dc.SubmitChanges();
                    Trace.WriteLine(String.Format("Creating Item {0} for company {1} Successfull.", item.itemCode, companyCode), "ProcessItem");
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(String.Format("Error Creating Item {0} for company {1}. Error: {2}", item.itemCode, companyCode, ex.Message), "ProcessItem");
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 34
0
        private void button_refreshcompany_Click(object sender, EventArgs e)
        {
            this.input_forceDB.Checked = false;

            CompanyClass db = new CompanyClass();
            db.Server = this.input_server.Text;
            db.DbUserName = this.input_serveruserid.Text;
            db.DbPassword = this.input_serverpassword.Text;
            db.UseTrusted = this.input_usetrusted.Checked;
            db.language = BoSuppLangs.ln_English;
            Recordset rs;
            try
            {
                rs = db.GetCompanyList();

                DataTable myTable = new DataTable("companies");
                DataColumn dbItem = new DataColumn("dbName", Type.GetType("System.String"));
                DataColumn cmpItem = new DataColumn("cmpName", Type.GetType("System.String"));
                DataColumn versItem = new DataColumn("versStr", Type.GetType("System.String"));

                myTable.Columns.Add(dbItem);
                myTable.Columns.Add(cmpItem);
                myTable.Columns.Add(versItem);
                DataView firstView = new DataView(myTable);

                int companyCount = rs.RecordCount;
                rs.MoveFirst();
                DataRow NewRow;
                for (int c = 0; c < companyCount; c++)
                {
                    NewRow = myTable.NewRow();
                    NewRow["dbName"] = rs.Fields.Item("dbName").Value;
                    NewRow["cmpName"] = rs.Fields.Item("cmpName").Value;
                    NewRow["versStr"] = rs.Fields.Item("versStr").Value;
                    myTable.Rows.Add(NewRow);
                    rs.MoveNext();
                }
                this.input_company.DataSource = firstView;
                this.input_company.DisplayMember = "cmpName";
                this.input_company.ValueMember = "dbName";
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Failed to get company list (perhaps you should try DB direct):" + ex.Message);
                return;
            }
        }
Ejemplo n.º 35
0
        private CompanyClass SetLoginInfo()
        {
            CompanyClass session = new CompanyClass();
            session.Server = this.input_server.Text;
            session.UserName = this.input_username.Text;
            session.Password = this.input_password.Text;
            session.DbUserName = this.input_serveruserid.Text;
            session.DbPassword = this.input_serverpassword.Text;
            session.UseTrusted = this.input_usetrusted.Checked;
            session.LicenseServer = this.input_licensesrv.Text;
            session.language = BoSuppLangs.ln_English;

            switch ((string)this.input_dbservertype.SelectedItem)
            {
                case "MSSQL2005":
                    session.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005;
                    break;
                case "MSSQL":
                    session.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL;
                    break;
                case "DB2":
                    session.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_DB_2;
                    break;
                case "SYBASE":
                    session.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_SYBASE;
                    break;
                default:
                    session.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005;
                    break;

            }
            return session;
        }